Queryable 3.0.0

Queryable 3.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2017
SwiftSwift Version 3
SPMSupports SPM

Maintained by Pawel Bednorz.



Queryable 3.0.0

Queryable

Realm Query Extension

codebeat badge Readme Score

Requirements

  • iOS 8.0+ / macOS 10.9+ / tvOS / watchOS
  • Xcode 8.0+
  • Swift 3.0+

Contribute

  • If you want to add something feels free to add pull request
  • If you find bug or suggestion, please create issue
  • Thanks for all starts

Usage

CUD operations

// 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()

Fetching objects

// Fetch all objects
_ = Foo.arrayOfObjects

// Realm results
_ = Foo.resultsOfObjects

// Fetch filtred array
_ = Foo.filtredArray("bar == 'something'")

// Fetch filtred results
_ = Foo.filtredResults("bar == 'something'")

DBManager

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

Remove all from Realm

public class func removeAll() -> Bool