API operations described above provide a way to retrieve a limited (initial) set of related data. In most real world scenarios, there may be more related objects than returned by Single Step, Two Step or Relation Depth Retrieval APIs. To obtain a complete set of related objects Backendless supports Relation Paging API described below.
- To understand the concept of paged data retrieval, see the Data retrieval with Paging section of the documentation.
2. When working with paging, it may be important to know the total size of the related collection. See the Get Object Count section for details on how to get the related objects count.
Flutter applications must use
LoadRelationsQueryBuilder which facilitates retrieval of related objects for a parent object. The class is responsible for maintaining the page size and offset parameters used in the paging process.
Before an instance of
LoadRelationsQueryBuilder can be used in a data retrieval request, it must be initialized as shown below. Notice the
relationName property which identifies a related column for which the related objects will be loaded:
LoadRelationsQueryBuilder<Map> loadRelationsQueryBuilder; loadRelationsQueryBuilder = LoadRelationsQueryBuilder.ofMap("NAME-OF-RELATED-COLUMN"); loadRelationsQueryBuilder.relationName = "NAME-OF-RELATED-COLUMN";
LoadRelationsQueryBuilder<CHILDCLASS> loadRelationsQueryBuilder; loadRelationsQueryBuilder = LoadRelationsQueryBuilder.of<CHILDCLASS>("NAME-OF-RELATED-COLUMN"); loadRelationsQueryBuilder.relationName = "NAME-OF-RELATED-COLUMN";
||Used in the "Custom Class" approach only. A Dart class which identifies the related table.|
||Name of the related column in the parent table for which the related objects will be retrieved.|
Once a query builder object is created, the following API can be used to retrieve a page of related objects:
Future<List<R>> Backendless.data.of("PARENT-TABLE-NAME").loadRelations<R>( String parentObjectId, LoadRelationsQueryBuilder<R> queryBuilder);
Future<List<R>> Backendless.data.withClass<PARENTCLASS>().loadRelations<R>( String parentObjectId, LoadRelationsQueryBuilder<R> queryBuilder)
||id of the object for which the related objects will be retrieved.|
||name of the table which contains the parent object identified by
LoadRelationsQueryBuilder class contains methods which recalculate
offset in order to obtain next, previous or a specific page. After loadRelationsQueryBuilder is modified, call the API shown above to get next, previous or a specific page of data.