https://github.com/flocked/fzrealm
A collection of extensions and enhancements for RealmSwift
https://github.com/flocked/fzrealm
Last synced: 3 months ago
JSON representation
A collection of extensions and enhancements for RealmSwift
- Host: GitHub
- URL: https://github.com/flocked/fzrealm
- Owner: flocked
- License: mit
- Created: 2023-05-25T00:06:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-13T16:24:47.000Z (7 months ago)
- Last Synced: 2025-01-04T06:43:34.393Z (5 months ago)
- Language: Swift
- Homepage:
- Size: 314 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FZRealm
A collection of Extensions to Realm.
It provides CustomPersistable conformance to many types (like URL, CGRect, CGPoint, CGSize and CMTime) so that they can be be used Realm Object properties.
## RealmObject protocol
A protocol that provides additional functionality to Realm Objects conforming to it (like saving, editing or deleting an object or fetching all).```
class Video: Object, RealmObject {
@Persisted var url: URL
@Persisted var date: URL
@Persisted var dimensions: CGSize
}let videos = try Video.all() // All video objects
let videos = try Video.all(where: {$0.date < someDate }) // All video objects before someDate
try Video.deleteAll() // Deletes all video objectslet video = Video() // new video object
try video.save() // save video
try video.edit { // edits video
$0.date = newDate
$0.url = newURL
}
try video.delete() // delets video
```