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 (optimised) 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
This orderBy(Obj name, Int sortOrder := Index.ASC)
Specifies a property / field to use for ordering.
name
may either an entityField
annotated with@Property
or a MongoDB property name (Str). If passing aStr
, it may be prefixed with-
to specify a descending order, otherwise ordering defaults to ascending.Multiple calls to
orderBy()
may be made to indicate sub-sorts. Example:QueryExecutor(...).orderBy("name").orderBy("-value").findAll
- orderByDoc
This orderByDoc(Str:Obj? sortDoc)
(Advanced) Allows you to specify your own sort document.
- orderByIndex
This orderByIndex(Str indexName)
Specifies an index to use for sorting.
- orderByTextScore
This orderByTextScore(Bool order := true)
When performing a text search, this orders the returned documents by search relevance. Should only be used with
findAll()
.Note that
Query.textSearch()
automatically sets text score ordering.- skip
Starts the query results at a particular zero-based offset.
Only used by
findAll()
.