const mixinafMorphia::Queries
afMorphia::Queries
Convenience shortcut methods for creating Query objects. These values mimic those on QueryCriterion.
const class MyQueries : Queries {
Query price() {
return and([
or([ eq("price", 0.99f), eq("price", 1.99f) ]),
or([ eq("sale", true), lessThan("qty", 29) ])
])
}
- and
Query and(Query q1, Query q2, Query? q3 := null, Query? q4 := null)Selects documents that pass all the query expressions in the given list. Example:
query := and( lessThan("quantity", 20), eq("price", 10) )Note the above could also be written as:
lessThan("quantity", 20).and([eq("price", 10)])@see http://docs.mongodb.org/manual/reference/operator/query/and/
- contains
Query contains(Str fieldName, Str value, Bool caseInsensitive := true)Matches string values that contain the given value.
Note that matching is performed with regular expressions.
- endsWith
Query endsWith(Str fieldName, Str value, Bool caseInsensitive := true)Matches string values that end with the given value.
Note that matching is performed with regular expressions.
- eq
Query eq(Str fieldName, Obj? value)Matches values that are equal to the given object.
- eqIgnoreCase
Query eqIgnoreCase(Str fieldName, Str value)Matches string values that equal (ignoring case) the given value.
Note that matching is performed with regular expressions.
- exists
Query exists(Str fieldName, Bool exists := true)Matches if the field exists (or not), even if it is
null.@see http://docs.mongodb.org/manual/reference/operator/query/exists/
- greaterThan
Query greaterThan(Str fieldName, Obj value)Matches values that are greater than the given object.
@see http://docs.mongodb.org/manual/reference/operator/query/gt/
- greaterThanOrEqTo
Query greaterThanOrEqTo(Str fieldName, Obj value)Matches values that are greater than or equal to the given object.
@see http://docs.mongodb.org/manual/reference/operator/query/gte/
- in
Query in(Str fieldName, Obj[] values)Matches values that equal any one of the given values.
@see http://docs.mongodb.org/manual/reference/operator/query/in/
- lessThan
Query lessThan(Str fieldName, Obj value)Matches values that are less than the given object.
@see http://docs.mongodb.org/manual/reference/operator/query/gt/
- lessThanOrEqTo
Query lessThanOrEqTo(Str fieldName, Obj value)Matches values that are less than or equal to the given object.
@see http://docs.mongodb.org/manual/reference/operator/query/lte/
- makeInstance
static new makeInstance()Returns an instance of
Queries. Use when you'd rather not inherit fromQueries.Query price() { q := Queries() return q.or([ q.eq("price", 0.99f), q.eq("price", 1.99f) ]) }- matchesRegex
Query matchesRegex(Str fieldName, Regex regex)Matches string values that equal the given regular expression.
- mod
Query mod(Str fieldName, Int divisor, Int remainder)Matches values based on their remainder after a division (modulo operation).
@see http://docs.mongodb.org/manual/reference/operator/query/mod/
- nor
Query nor(Query q1, Query q2, Query? q3 := null, Query? q4 := null)Selects documents that fail all the query expressions in the given list. Example:
query := nor( lessThan("quantity", 20), eq("price", 10) )@see http://docs.mongodb.org/manual/reference/operator/query/nor/
- not
QueryCriterion not(QueryCriterion query)Selects documents that do not match the given following criterion. Example:
not(Query.field("price")).lessThan(10)Note this also matches documents that do not contain the field.
@see http://docs.mongodb.org/manual/reference/operator/query/not/
- notEq
Query notEq(Str fieldName, Obj? value)Matches values that are not equal to the given object.
Note this also matches documents that do not contain the field.
@see http://docs.mongodb.org/manual/reference/operator/query/ne/
- notIn
Query notIn(Str fieldName, Obj[] values)Matches values that do not equal any one of the given values.
Note this also matches documents that do not contain the field.
@see http://docs.mongodb.org/manual/reference/operator/query/nin/
- or
Query or(Query q1, Query q2, Query? q3 := null, Query? q4 := null)Selects documents that pass any of the query expressions in the given list. Example:
query := or( lessThan("quantity", 20), eq("price", 10) )@see http://docs.mongodb.org/manual/reference/operator/query/or/
- startsWith
Query startsWith(Str fieldName, Str value, Bool caseInsensitive := true)Matches string values that start with the given value.
Note that matching is performed with regular expressions.