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

Source

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

Source

Query contains(Obj name, Str value, Bool caseInsensitive := true)

Matches string values that contain the given value.

Note that matching is performed with regular expressions.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

endsWith

Source

Query endsWith(Obj name, Str value, Bool caseInsensitive := true)

Matches string values that end with the given value.

Note that matching is performed with regular expressions.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

eq

Source

Query eq(Obj name, Obj? value)

Matches values that are equal to the given object.

name may either a MongoDB property name (Str) or a field annotated with @Property.

eqIgnoreCase

Source

Query eqIgnoreCase(Obj name, Str value)

Matches string values that equal (ignoring case) the given value.

Note that matching is performed with regular expressions.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

exists

Source

Query exists(Obj name, Bool exists := true)

Matches if the field exists (or not), even if it is null.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/exists/

greaterThan

Source

Query greaterThan(Obj name, Obj value)

Matches values that are greater than the given object.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/gt/

greaterThanOrEqTo

Source

Query greaterThanOrEqTo(Obj name, Obj value)

Matches values that are greater than or equal to the given object.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/gte/

in

Source

Query in(Obj name, Obj[] values)

Matches values that equal any one of the given values.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/in/

lessThan

Source

Query lessThan(Obj name, Obj value)

Matches values that are less than the given object.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/gt/

lessThanOrEqTo

Source

Query lessThanOrEqTo(Obj name, Obj value)

Matches values that are less than or equal to the given object.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/lte/

makeInstance

Source

static new makeInstance()

Returns an instance of Queries. Use when you'd rather not inherit from Queries.

Query price() {
    q := Queries()
    return q.or([
        q.eq("price", 0.99f), 
        q.eq("price", 1.99f)
    ])
}
matchesRegex

Source

Query matchesRegex(Obj name, Regex regex)

Matches string values that equal the given regular expression.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

mod

Source

Query mod(Obj name, Int divisor, Int remainder)

Matches values based on their remainder after a division (modulo operation).

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/mod/

nor

Source

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

Source

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

Source

Query notEq(Obj name, Obj? value)

Matches values that are not equal to the given object.

Note this also matches documents that do not contain the field.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/ne/

notIn

Source

Query notIn(Obj name, 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.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).

@see http://docs.mongodb.org/manual/reference/operator/query/nin/

or

Source

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

Source

Query startsWith(Obj name, Str value, Bool caseInsensitive := true)

Matches string values that start with the given value.

Note that matching is performed with regular expressions.

name may either an entity Field annotated with @Property or a MongoDB property name (Str).