Skip to content

General Object Retrieval API

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.
  • Calculating aggregate values for a collection of objects - retrieves sum, average, min, max or count for all or a subset of objects in a table. See Aggregate Functions for more details.

Backendless supports data retrieval options listed above with a special class - DataQueryBuilder. An instance of DataQueryBuilder can be passed into the find operation to retrieve data from the server according to the options set in the query builder object. The class provides the following methods:

Argument                Description
setWhereClause sets a search query. A query must be in the SQL-92 syntax (the "where" clause part).
setSortBy sets an array of column names to sort the data objects in the response by.
setRelated sets an array of related columns names. Objects from the related columns are included into the response.
setRelationsDepth sets the number of "levels" in the hierarchy of related objects to include into the response.
setPageSize sets the page size - which is the number of objects to return in the response. Maximum value is 100.
setOffset sets the offset - an index in the server-side storage from where the data objects should be retrieved.
setGroupBy used with Aggregate Functions. Sets the name of a column to group the results by.
setHavingClause used with Aggregate Functions. Sets a condition on a aggregate function to filter groups.

To run a query-based search, use the following API methods:

- (void)findWithQueryBuilder:(DataQueryBuilder * _Nonnull)queryBuilder responseHandler:^(NSArray * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func find(queryBuilder: DataQueryBuilder, responseHandler: (([Any]) -> Void)!, errorHandler: ((Fault) -> Void)!)
- (void)findWithQueryBuilder:(DataQueryBuilder * _Nonnull)queryBuilder responseHandler:^(NSArray<NSDictionary<NSString *,id> *> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func find(queryBuilder: DataQueryBuilder, responseHandler: (([[String : Any]]) -> Void)!, errorHandler: ((Fault) -> Void)!)


Argument                Description
queryBuilder an instance of DataQueryBuilder - contains the search query and other search options.

Return Value

Returns a collection of strongly typed data objects retrieved as a result of the query execution.


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