mirror of
https://github.com/sudoxnym/audiobookshelf-atv.git
synced 2026-07-17 09:22:28 +00:00
Provide DAO methods for Realm objects
This commit is contained in:
parent
5d31499fd6
commit
ac2a1ce079
1 changed files with 16 additions and 0 deletions
|
|
@ -94,3 +94,19 @@ extension URL {
|
|||
return attributes?[.creationDate] as? Date
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - DAO Methods
|
||||
extension Object {
|
||||
func save() {
|
||||
let realm = try! Realm()
|
||||
try! realm.write {
|
||||
realm.add(self, update: .modified)
|
||||
}
|
||||
}
|
||||
|
||||
func update(handler: () -> Void?) {
|
||||
try! self.realm?.write {
|
||||
handler()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue