classafMorphia::QueryExecutor
sys::Obj afMorphia::QueryExecutor
Executes Query objects against a Datastore. Example:
QueryExecutor(datastore, query).skip(10).limit(50).orderBy("name").findAll
Or you can use the instance returned by Datastore.query(...)
:
datastore.query(query).orderBy("name").findAll
- findAll
Obj[] findAll()
Returns a list of entities that match the query.
- findCount
Int findCount()
Returns the number of documents that would be returned by the query.
- findOne
Obj? findOne(Bool checked := true)
An (optomised) method to return one document from the query.
Throws
MongoErr
if no documents are found andchecked
istrue
, returnsnull
otherwise. Always throwsMongoErr
if the query returns more than one document.- limit
Limits the fetched result set to a certain number of values. A value of
null
or0
indicates no limit.Only used by
findAll()
.- make
new make(Datastore datastore, Query query)
Creates a
QueryExecutor
to run the given query against the datastore.- mongoQuery
Returns a Mongo document representing the query. May be used by Datastore and Collection methods such as
findAndUpdate(...)
.- orderBy
Specifies a property / field to use for ordering.
Ordering is ascending by default. Prefix the name with
-
to specify a descending order.Multiple calls to
orderBy()
may be made to indicate sub-sorts. Example:QueryExecutor(...).orderBy("name").orderBy("-value").findAll
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.- orderByIndex
This orderByIndex(Str indexName)
Specifies an index to use for sorting.
- skip
Starts the query results at a particular zero-based offset.
Only used by
findAll()
.