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

Source

Obj[] findAll()

Returns a list of entities that match the query.

@see afMongo::Collection.findAll

findCount

Source

Int findCount()

Returns the number of documents that would be returned by the query.

@see afMongo::Collection.findCount

findOne

Source

Obj? findOne(Bool checked := true)

An (optimised) method to return one document from the query.

Throws MongoErr if no documents are found and checked is true, returns null otherwise. Always throws MongoErr if the query returns more than one document.

@see afMongo::Collection.findOne

limit

Source

This limit(Int? limit)

Limits the fetched result set to a certain number of values. A value of null or 0 indicates no limit.

Only used by findAll().

make

Source

new make(Datastore datastore, Query query)

Creates a QueryExecutor to run the given query against the datastore.

mongoQuery

Source

Str:Obj? mongoQuery()

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

orderBy

Source

This orderBy(Obj name, Int sortOrder := Index.ASC)

Specifies a property / field to use for ordering.

name may either an entity Field annotated with @Property or a MongoDB property name (Str). If passing a Str, 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

Source

This orderByDoc(Str:Obj? sortDoc)

(Advanced) Allows you to specify your own sort document.

orderByIndex

Source

This orderByIndex(Str indexName)

Specifies an index to use for sorting.

orderByTextScore

Source

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.

Source

This skip(Int skip)

Starts the query results at a particular zero-based offset.

Only used by findAll().