Class: QueryRequest

QueryRequest(targetTypenon-null, clientnon-null, actorRequestFactorynon-null)

A request to retrieve entities of the given type. Allows to post the query data to the Spine backend and receive the entity states as `Promise`. A usage example: ``` const customers = client.select(Customer.class) .byId(westCoastCustomerIds()) .withMask("name", "address", "email") .where([Filters.eq("type", "permanent"), Filters.eq("discount_percent", 10), Filters.eq("company_size", Company.Size.SMALL)]) .orderBy("name", OrderBy.Direction.ASCENDING) .limit(20) .run(); // The returned type is `Promise`. ``` All of the called filtering methods are optional. If none of them are specified, all entities of type will be retrieved.

Constructor

new QueryRequest(targetTypenon-null, clientnon-null, actorRequestFactorynon-null)

Parameters:
Name Type Description
targetType Class.<Message> the target type of entities
client Client the client which initiated the request
actorRequestFactory ActorRequestFactory the request factory
Source:

Classes

QueryRequest

Methods

_newBuilderFn()

Source:

_self()

Source:

limit(count) → {this}

Sets the maximum number of returned entities. Can only be used in conjunction with the #orderBy condition.
Parameters:
Name Type Description
count number the max number of response entities
Source:
Returns:
self for method chaining
Type
this

orderBy(columnnon-null, directionnon-null) → {this}

Sets the sorting order for the retrieved results.
Parameters:
Name Type Description
column String the column to order by
direction OrderBy.Direction the ascending/descending direction
Source:
Returns:
self for method chaining
Type
this

query() → {spine.client.Query}

Builds a `Query` instance based on currently specified filters.
Source:
Returns:
a `Query` instance
Type
spine.client.Query

run() → {Promise.<Array.<Message>>}

Runs the query and obtains the results.
Source:
Returns:
the asynchronously resolved query results
Type
Promise.<Array.<Message>>