Support Topics Documentation Slack YouTube Blog

Autoload relation pageSize


(Francesco Signorile) #1

I have an object with more than 100 related objects. Autoload is checked, so when I call a query for that object, I retrieve all the related objects.
I thought that with autoload enabled, I could retrieve only 100 objects at time but I can retrieve all the objects related to the main object and they are more than 100, 153 to be exact…


(Mark Piller) #2

Francesco,

Currently Backendless returns all related objects when auto-load is turned on. This will be changing soon as we’re introducing paging for the related entities.

Regards,
Mark


(Jonathan ) #3

What is the way to get more than 10 relations and also get the relations’ relations? LoadRelationsQueryBuilder on iOS seems very limiting in that it can’t get the relations of my relations. Does autoload work to get these relations and can I get more than 10, say 30 child relations?


(Sergey Chupov) #4

With autoload you can only get 10 relations. To load more, you can use LoadRelationsQueryBuilder. To load relations of relations, you just need to specify them dot-separated, e.g. “shop.owner” if you have relation column “shop” to a table containing a relation column “owner”.


(Jonathan ) #5

So if I have an Franchise object that has 20 shops in “shop” column and each shop has 20 owners in “owner” and each owner has 20 employees in “employee” column then you’re saying if I use LoadRelationsQueryBuilder and pass the argument “shop.owner.employee” and it will return all of the shops, owners, and employees of the franchise?


(Sergey Chupov) #6

Yes, exactly. Specifying “shop.owner.employee” as a relation to load will load all the employees, owners and shops down this chain.


(Jonathan ) #7

I just had a chance to try this out and I get a Fault 1054 ‘Column does not exist in table’ when I pass the dot-separated relations to the relationName property of the LoadRelationsQueryBuilder. Are you sure this is supposed to work as you described?


(Sergey Chupov) #8

Hello Jonathan,
There’s a probability that we’ve been testing two different approaches :slight_smile: Can you please provide the part of code you use to load relations?


(Jonathan ) #9

Here is my code

let franchise: IDataStore = Backendless.sharedInstance().data.of(Franchise.ofClass())
let relationQuery = LoadRelationsQueryBuilder()
relationQuery.setRelationName("shops.owners.employees")
let relations = franchise.loadRelations(objectId, queryBuilder: relationQuery)

(Jonathan ) #10

Is this code correct?


(Sergey Chupov) #11

Indeed, you cannot load multiple levels of relations in one request with LoadRelationsQueryBuilder. Sorry for misguiding you. For now, you’ll have to load the relations level by level, for each object.


(Jonathan ) #12

This seems very limited in my opinion. I may end up having to make 100s of API requests. In the old version we were able to get all of our relations, now only 10. That may be optimal from a server perspective, but from app perspective it is very limiting. There should be a property in relations query to set the number of relation objects.


(Anton Govorushkin) #13

Hey Jonathan

Will shall discuss this and will inform you regarding the decision we’ve made as soon as we have one.

Anton