TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2017 |
SwiftSwift Version | 3 |
SPMSupports SPM | ✗ |
Maintained by Pawel Bednorz.
Realm Query Extension
// Simple class
class Foo: Object {
dynamic var bar = ""
}
// Conform to protocol
extension Foo: Queryable {}
// Create simple object
let foo = Foo()
foo.bar = "something"
// Save objec
foo.add()
// Update object
foo.update(transaction: {
foo.bar = "something other"
}, completion: nil)
// Remove object
foo.remove()
// Fetch all objects
_ = Foo.arrayOfObjects
// Realm results
_ = Foo.resultsOfObjects
// Fetch filtred array
_ = Foo.filtredArray("bar == 'something'")
// Fetch filtred results
_ = Foo.filtredResults("bar == 'something'")
Queryable has also DBManger which provides generic methods
// Fetching objects
public class func getObjects<T: Object>(of entity: T.Type, filter: String? = nil) -> [T]
// Add
public class func add(object: Object) -> Bool
//Update
public class func update(transaction: @escaping ()->()) -> Bool
//Remove
public class func remove(object: Object) -> Bool
public class func removeAll() -> Bool