Advanced Object Retrieval

Top  Previous  Next

Advanced search use-cases supported by Backendless include:

Search with a query (a "where clause" search) -retrieves data objects which satisfy a condition;
Paged data retrieval - retrieves a "page" of data of the given size from the specified offset.
Sorted data object retrieval - retrieves a collection of data objects sorted by specified properties.
Retrieval of related objects - fetching data objects through special "relation" properties. See retrieval of related data objects.

 

Backendless supports the use-cases and modifiers listed above with a special class - BackendlessDataQuery. The class includes various properties to request data retrieval from the server using paging and/or sorting, specify a search query (the where clause), and/or to request loading of specific relations. For information about relation retrieval, see the Relations (Retrieve) chapter of the documentation.

 

Method Signature:

Synchronous Method:

// Notice the data type of the "result" variable. 
// It is a collection of java.util.Map objects; 
BackendlessCollection<Map> result;

// The data table must be identified by name. The API
// returns a collection of Map objects.
result = Backendless.Persistence.of( "TABLE-NAME" ).find( BackendlessDataQuery query );
BackendlessCollection<E> result = Backendless.Persistence.of( E ).find( BackendlessDataQuery query );

Asynchronous Method:

Backendless.Persistence.of( "TABLE-NAME" ).find( BackendlessDataQuery query, 
                                                 AsyncCallback<BackendlessCollection<Map>> );
Backendless.Persistence.of( E ).find( BackendlessDataQuery query, 
                                      AsyncCallback<BackendlessCollection<E>> );

where:

TABLE-NAME- Name of the table to retrieve data from.
E- Java class identifying the table to retrieve data from. The name of the class must match the name of the table.
query- an instance of BackendlessDataQuery - containing the search query and other search options.
responder- a responder object which will receive a callback when the search operation returns the result. Applies to the asynchronous method only.

Return Value:

The synchronous method returns a collection of strongly typed objects found as a result of the query execution. The asynchronous call receives the return value through a callback executed on the AsyncCallback object.

Examples

For examples on using the advanced object retrieval API, see the following sub-sections:

Search with where clause
Using dates in search
Retrieval with paging
Retrieval with sorting
Search by distance

Please let us know how we can improve the documentation by leaving a comment. All technical questions should be posted to the Backendless Support forum. We do not respond to the technical questions on the documentation pages.: