mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-26 21:55:33 +02: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
|
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…
Add table
Add a link
Reference in a new issue