QueryRequest

public final class QueryRequest<S extends EntityState> extends FilteringRequest<M, R, A, B>

Allows to create a post a query for messages of the given type.

None of the parameters set by the builder methods are required. Call run to retrieve the results of the query.

Usage example:


ImmutableList<Customer> customers = client.onBehalfOf(currentUser)
         .select(Customer.class)
         .byId(westCoastCustomerIds())
         .withMask("name", "address", "email")
         .where(eq(Customer.Column.type(), "permanent"),
                eq(Customer.Column.discountPercent(), 10),
                eq(Customer.Column.companySize(), Company.Size.SMALL))
         .orderBy(Customer.Column.name(), ASCENDING)
         .limit(20)
         .run();

Filtering by field values (via where and where methods) can be composed using the Filters utility class.

Parameters

<S>

the type of the queried entity states

See also

Functions

Link copied to clipboard
public QueryRequest<S> limit(int count)
Limits the number of results returned by the query.
Link copied to clipboard
public QueryRequest<S> orderBy(EntityColumn column, Direction direction)
public QueryRequest<S> orderBy(String column, Direction direction)
Sets the sorting order by the target column and order direction.
Link copied to clipboard
public ImmutableList<S> run()
Obtains results of the query.
Link copied to clipboard
public QueryRequest<S> where(Array<QueryFilter> filter)
Configures the request to return results matching all the passed filters.

Inherited functions

Link copied to clipboard
public B byId(Array<Message> ids)
public B byId(Array<Integer> ids)
public B byId(Iterable<? extends Object> ids)
public B byId(Array<Long> ids)
public B byId(Array<String> ids)
Requests only passed IDs to be included into the result of the request.
Link copied to clipboard
protected final Client client()
Obtains the client instance that will perform the request.
Link copied to clipboard
public CommandRequest command(CommandMessage c)
Creates a builder for customizing command request.
Link copied to clipboard
Assigns a handler for an error occurred on the server-side (such as validation error) in response to posting a request.
Link copied to clipboard
Assigns a handler for errors occurred when delivering messages from the server.
Link copied to clipboard
public QueryRequest<S> select<S extends EntityState>(Class<S> type)
Creates a builder for constructing a query for messages of the specified type.
Link copied to clipboard
public SubscriptionRequest<S> subscribeTo<S extends EntityState>(Class<S> type)
Creates a builder for customizing subscription for the passed entity state type.
Link copied to clipboard
public EventSubscriptionRequest<E> subscribeToEvent<E extends EventMessage>(Class<E> type)
Creates a builder for customizing subscription for the passed event type.
Link copied to clipboard
protected final UserId user()
Obtains the ID of the user of the request.
Link copied to clipboard
public B where(Array<CompositeFilter> filter)
public B where(Array<Filter> filter)
Configures the request to return results matching all the passed filters.
Link copied to clipboard
public B withMask(Iterable<String> fieldNames)
public B withMask(Array<String> fieldNames)
Instructs to populate only fields with the passed names in the results of the request.