classafMorphia::Query

sys::Obj
  afMorphia::Query

A means to build Mongo queries with sane objects and methods. (And not some incomprehensible mess of nested maps and lists!)

Pass Query objects to a QueryExecutor to run them.

and

Source

Query and(Query[] criteria)

Selects documents that pass all the query expressions in the given list. Example:

Query().and([
  Query().field("quantity").lessThan(20),
  Query().field("price").eq(10)
])

Note the above could also be written implicitly with:

Query().field("quantity").lessThan(20).field("price").eq(10)

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

field

Source

QueryCriterion field(Str fieldName)

Creates a match for the given field name. It may reference nested objects using dot notation. Example, user.name

Note this is actually the MongoDB property name and not the field name. Though, the two are usually the same unless you use the @Property.name attribute.

nor

Source

Query nor(Query[] criteria)

Selects documents that fail all the query expressions in the given list. Example:

Query().or([
  Query().field("quantity").lessThan(20),
  Query().field("price").eq(10)
])

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

or

Source

Query or(Query[] criteria)

Selects documents that pass any of the query expressions in the given list. Example:

Query().or([
  Query().field("quantity").lessThan(20),
  Query().field("price").eq(10)
])

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

toMongo

Source

Str:Obj toMongo(Datastore datastore)

Returns a Mongo document representing the query. May be used by Datastore and Collection methods such as findAndUpdate(...).

where

Source

Query where(Code where)

Selects documents based on the return value of a javascript function. Example:

Query().where(Code("this.name == 'Judge Dredd'"))

As only 1 where function is allowed per query, only the last where function is used.

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