Hello, I follow this document Retrieving objects - Backendless SDK for Flutter API Documentation
The document said " This operation retrieves data objects from a database table. The retrieval is performed according to the provided options, which allow you to:
- Retrieve objects with a query
- Using paging
- Using sorting
- With related objects"
But It’s only working with whereClause/pageSize property.
related/sortBy/offset property is not working.
My code here:
final unitOfWork = UnitOfWork();
DataQueryBuilder findCommentsBuilder = DataQueryBuilder();
findCommentsBuilder.whereClause = "eventId = '$eventId'";
findCommentsBuilder.related = ["createdBy"];
findCommentsBuilder.sortBy = ["created DESC"];
findCommentsBuilder.pageSize = 20;
findCommentsBuilder.offset = 0;
findCommentsBuilder.addAllProperties();
final findCommentsResult =
unitOfWork.find(BLComment.tableName, findCommentsBuilder);
findCommentsResultJsonKey = findCommentsResult.opResultId;
unitOfWork.execute()
The result returns 20 comment records without related “createdBy” object, wrong sortBy, wrong offset.
It’s working perfect If I don’t use transactions as below code
String query = "eventId = '$eventId'";
DataQueryBuilder queryBuilder = DataQueryBuilder();
queryBuilder.whereClause = query;
queryBuilder.related = ["createdBy"];
queryBuilder.sortBy = ["created DESC"];
queryBuilder.pageSize = 20;
queryBuilder.offset = 0;
queryBuilder.addAllProperties();
Backendless.data.of(BLComment.tableName).find(queryBuilder)
the result will be as expected
But we need to use Transaction to handle our case.