Load specific properties in one to many relationships

Hey! I have two tables Brand and Model. Brand has a one to many relationship with model. The property of the relation in Brand is called models. I want to load specific properties of Brand and specific properties of the Model within brands. After reading the documentation about related-object-properties I wrote this code:

export function loadBrands(): Promise<Brand[]> {
  const queryBuilder = Backendless.DataQueryBuilder.create();
  queryBuilder.addProperties('objectId', 'name', 'models.name', 'models.objectId')
  queryBuilder.setRelated( ["models"] );
  const promise = Backendless.Data.of('Brand').find<Brand>(queryBuilder);
  return promise;

This throws the error: ‘Unable to execute query. Combining one-to-many relations (and/or relation depth) and named properties from one-to-many related tables produces an invalid query. Possible solution - choose either the entire relation column or named relation properties.’

Just using 'models' instead of 'models.name', 'models.objectId' works, however it adds attributes like created etc. which I don’t need. Additionally, is there some way to eliminate the ___class attribute?

Hello @Christian_Stippel!
Welcome to our community and thank you for trying out Backendless.

You can exclude unnecessary parameters from your query using the excludeProperty or excludeProperties methods.

You can find more information about excluding properties here:
Working wih Properties - Backendless SDK for JavaScript API Documentation.

But unfortunately there is no way to eliminate the ___class attribute.