Filter
public class Filter
A Filter that can be used for queries.
Example:
Devices activated in the last hour that implement a com:acme:device
device model.
The following code:
f = Filter.and(
Filter.gte(Device.Field.CREATED.alias(),
(System.currentTimeMillis() - 3600000L)),
Filter.eq(Device.Field.STATE.alias(), "ACTIVATED"),
Filter.like(Device.Field.DEVICE_MODELS.alias() + ".urn",
"urn:com:acme:device:%"));
will create the following Json object:
{"$and":[
{"created":{"$gte":1457137772894}},
{"state":{"$eq":"ACTIVATED"}},
{"deviceModels.urn":{"$like":"urn:com:acme:device:%"}}]}
-
Creates a query filter that performs the logical AND between sub filters provided as argument:
(filter1 and filter2 and ...)
.Declaration
Swift
public static func and(filters: [Filter]) -> Filter
Parameters
filters
Sub filters to combine.
Return Value
A new filter
{ "$and": [ filter1, filter2, .... ] }
. -
Creates a query filter that performs the logical OR between sub filters provided as argument:
(filter1 or filter2 or ...)
.Declaration
Swift
public static func or(filters: [Filter]) -> Filter
Parameters
filters
Sub filters to combine.
Return Value
A new filter
{ "$or": [ filter1, filter2, .... ] }
. -
Creates a query filter that performs the logical NOT on the filter provided as argument:
(not filter)
.Declaration
Swift
public static func not(filter: Filter) -> Filter
Parameters
filter
filter on which to apply the NOT.
Return Value
A new filter
{ "$not": filter }
. -
Creates a query filter that performs
(op1 == op2)
.Declaration
Swift
public static func eq(op1: String, op2: String) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$eq": op2 } }
. -
Creates a query filter that performs
(op1 == op2)
.Declaration
Swift
public static func eq(op1: String, op2: Double) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$eq": op2 } }
. -
Creates a query filter that performs
(op1 == op2)
.Declaration
Swift
public static func eq(op1: String, op2: Bool) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$eq": op2 } }
. -
Creates a query filter that performs
(op1 == op2)
.Declaration
Swift
public static func eq(op1: String, op2: CLongLong) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$eq": op2 } }
. -
Creates a query filter that checks if
op1
exists.Declaration
Swift
public static func exists(op1: String, e: Bool) -> Filter
Parameters
op1
First operand.
e
Either
true
to check that exists, orfalse
to check that not exists.Return Value
A new filter performing
{ op1: { "$exists" : true/false }}
. -
Creates a query filter that checks if the value matches the pattern.
Declaration
Swift
public static func like(value: String, pattern: String) -> Filter
Parameters
value
The value to check.
pattern
The pattern to match.
Return Value
A new filter performing
{ op1: { "$like" : pattern }}
. -
Creates a query filter that performs
(key IN [value1, value2, ...])
.Declaration
Swift
public static func _in(key: String, values: [String]) -> Filter
Parameters
key
The key to check.
values
The list of values to compare with.
Return Value
A new filter
{ key: { "$in" : [value1, value2, ...] }}
. -
Creates a query filter that performs
(key IN [value1, value2, ...])
.Declaration
Swift
public static func _in(key: String, values: [CLongLong]) -> Filter
Parameters
key
The key to check.
values
The list of values to compare with.
Return Value
A new filter
{ key: { "$in" : [value1, value2, ...] }}
. -
Creates a query filter that performs
(key IN [value1, value2, ...])
Declaration
Swift
public static func _in(key: String, values: [Double]) -> Filter
Parameters
key
The key to check.
values
The list of values to compare with.
Return Value
A new filter
{ key: { "$in" : [value1, value2, ...] }}
. -
Creates a query filter that performs
(key IN [value1, value2, ...])
.Declaration
Swift
public static func _in(key: String, values: [Bool]) -> Filter
Parameters
key
The key to check.
values
The list of values to compare with.
Return Value
A new filter
{ key: { "$in" : [value1, value2, ...] }}
. -
Creates a query filter that performs
(op1 != op2)
.Declaration
Swift
public static func ne(op1: String, op2: String) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$ne": op2 } }
. -
Creates a query filter that performs
(op1 != op2)
.Declaration
Swift
public static func ne(op1: String, op2: CLongLong) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$ne": op2 } }
. -
Creates a query filter that performs
(op1 != op2)
.Declaration
Swift
public static func ne(op1: String, op2: Double) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$ne": op2 } }
. -
Creates a query filter that performs
(op1 != op2)
.Declaration
Swift
public static func ne(op1: String, op2: Bool) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$ne": op2 } }
. -
Creates a query filter that performs
(op1 <= op2)
.Declaration
Swift
public static func lte(op1: String, op2: CLongLong) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$lte": op2 } }
. -
Creates a query filter that performs
(op1 <= op2)
.Declaration
Swift
public static func lte(op1: String, op2: Double) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$lte": op2 } }
. -
Creates a query filter that performs
(op1 >= op2)
.Declaration
Swift
public static func gte(op1: String, op2: CLongLong) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$gte": op2 } }
. -
Creates a query filter that performs
(op1 >= op2)
.Declaration
Swift
public static func gte(op1: String, op2: Double) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$gte": op2 } }
. -
Creates a query filter that performs
(op1 < op2)
.Declaration
Swift
public static func lt(op1: String, op2: CLongLong) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$lt": op2 } }
. -
Creates a query filter that performs
(op1 < op2)
.Declaration
Swift
public static func lt(op1: String, op2: Double) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$lt": op2 } }
. -
Creates a query filter that performs
(op1 > op2)
.Declaration
Swift
public static func gt(op1: String, op2: CLongLong) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$gt": op2 } }
. -
Creates a query filter that performs
(op1 > op2)
.Declaration
Swift
public static func gt(op1: String, op2: Double) -> Filter
Parameters
op1
First operand.
op2
Second operand.
Return Value
A new filter
{ op1: { "$gt": op2 } }
.