Get all relation will loading table (under 100 relation per record)

dear all,

I trying to get a table called dep that has a relation in field called codes.
there are no more then 100 codes per dep, but the limit is 10.
I tried all I know, but I missing something.
how can I do that.

here is the code I tried, but because of promise, I can not achieve it.

for (var counter=0;counter<systemDepTypes.length;counter+=1)
var codeBuilder = Backendless.DataQueryBuilder.create();
//query for each item…
var myCodes=[];
var whereClause=“dep=’”+systemDepTypes[counter].name+"’"
codeBuilder.setPageSize( 100 ).setOffset( 0 );
codeBuilder.setWhereClause( whereClause );
Backendless.Data.of( $
.then( function( result ) {
for (var codeCount=0;codeCount<result.length;codeCount+=1)
.catch( function( error ) {

  //console.log(systemDepTypes[counter].name+" codes:"+myCodes.length);

please help

You should try two-step retrieval (see here how to do it:
In two words, first you retrieve parent object and then you take it’s objectId and retrieve it’s relations using method
Backendless.Data.of(TableName).loadRelations(parentObjectId, loadRelationsQueryBuilder)

will give it a try again, last time, not worked correctly.
still I have problem with findSync, it’s not loading all the info :frowning:

Sync method should not load all the relations. They are limited to 10 in that way you are loading them. But LoadRelations API gives you the possibility to load any quantity of related objects (still don’t forget that one page may contain no more that 100 objects).

tried, not working

here is the code:

for (var counter=0;counter<systemDepTypes.length;counter+=1)
var parentObjectId = systemDepTypes[counter].objectId;
var loadRelationQueryBuilder = Backendless.LoadRelationQueryBuilder.create();

Each call to server returns a Promise object that you should handle properly.
Here you are making a call to server and without waiting to response trying to get some values. Moreover, loadRelations does not write result into parent object. It’s just return an array of related objects.
So here you should do something like this:

Backendless.Data.of($rootScope.Classes.dep).loadRelations(parentObjectId, loadRelationQueryBuilder)
.then(codes => { // do something with your codes. Here you have parentObject id and it's codes array})

I understand that, but since I using .then, the result can not update my global variable which need to hold all the info inside :frowning: