Filter

public class Filter: DictionaryLiteralConvertible

An instance of the Filter class is used to filter query results All filters are automatically converted into SQLite statements when querying the database.

To make filtering easier, and backwards compatibility, it is possible to instantiate a filter object as a dictionary literal

Example:

Return any objects with the name ‘Ghost’

let filter: Filter = ["name": "Ghost"]

let filter = Filter.equal("name", value: "Ghost")

  • Initialize a Filter object using a dictionary. All property-value pairs will limit the results to objects where property’s value is equal to the provided value

    Declaration

    Swift

    public required init(dictionaryLiteral elements: (Key, Value)...)
  • Initialize a new, empty Filter object

    Declaration

    Swift

    public init() {}
  • Evaluated as true if the value of the property is equal to the provided value

    Declaration

    Swift

    public func equal(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property is less than the provided value

    Declaration

    Swift

    public func lessThan(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property is greater than the provided value

    Declaration

    Swift

    public func greaterThan(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property is not equal to the provided value

    Declaration

    Swift

    public func notEqual(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property is contained in the array

    Declaration

    Swift

    public func contains(propertyName: String, array: [SQLiteValue?]) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should contain the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property is not contained in the array

    Declaration

    Swift

    public func notContains(propertyName: String, array: [SQLiteValue?]) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should not contain the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property matches the pattern.

    % matches any string

    _ matches a single character

    ‘Dog’ LIKE ’D_g’ = true

    ‘Dog’ LIKE ’D%’ = true

    Declaration

    Swift

    public func like(propertyName: String, pattern: String) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should contain the property value

    Return Value

    self, to enable chaining of statements

  • Evaluated as true if the value of the property matches the pattern.

    % matches any string

    _ matches a single character

    ‘Dog’ NOT LIKE ’D_g’ = false

    ‘Dog’ NOT LIKE ’D%’ = false

    Declaration

    Swift

    public func notLike(propertyName: String, pattern: String) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should contain the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property is equal to the provided value

    Declaration

    Swift

    public class func equal(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property is less than the provided value

    Declaration

    Swift

    public class func lessThan(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property is greater than the provided value

    Declaration

    Swift

    public class func greaterThan(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property is not equal to the provided value

    Declaration

    Swift

    public class func notEqual(propertyName: String, value: SQLiteValue?) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    value that will be compared to the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property is contained in the array

    Declaration

    Swift

    public class func contains(propertyName: String, array: [SQLiteValue?]) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should contain the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property is not contained in the array

    Declaration

    Swift

    public class func notContains(propertyName: String, array: [SQLiteValue?]) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should not contain the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property matches the pattern.

    % matches any string

    _ matches a single character

    ‘Dog’ LIKE ’D_g’ = true

    ‘Dog’ LIKE ’D%’ = true

    Declaration

    Swift

    public class func like(propertyName: String, pattern: String) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should contain the property value

    Return Value

    Filter intance

  • Evaluated as true if the value of the property matches the pattern.

    % matches any string

    _ matches a single character

    ‘Dog’ NOT LIKE ’D_g’ = false

    ‘Dog’ NOT LIKE ’D%’ = false

    Declaration

    Swift

    public class func notLike(propertyName: String, pattern: String) -> Filter

    Parameters

    propertyName

    name of the property to be evaluated

    array

    array that should contain the property value

    Return Value

    Filter intance

  • Generates a list of tuples containing statements and values from the filter components

    Declaration

    Swift

    public func generate() -> IndexingGenerator<[(String, Any?)]>