Get relation objects from table

Setup:
Table “Favorite” which consists of two relation fields: “user” and “product”.
I want to get a list of all products where user.username = ‘userme’;
I can get the results using:




var query = new Backendless.DataQuery();
query.options = {relations:["product"]};
query.condition = "user.username = 'userme'";
var resultCollection = Backendless.Persistence.of( "Favorite" ).find( query );
console.log(resultCollection);

However this returns an array of objects which refer to the product: [{ product : PRODUCT }, …].
My question: is it possible to simply get an array of products: [PRODUCT, PRODUCT], and if so how?

Hi Jonas,

You can try to use this where clause:

Favorite[user].username='userme'

and query Priduct table instead of Favorite:

Backendless.Persistence.of( "Product" ).find( query)

This is described in more detailed on this doc page: https://backendless.com/documentation/data/js/data_relations_retrieve.htm#subsetofchildren

EDIT: it doesn’t work, how do you do it?

var dataQuery = new Backendless.DataQuery();
dataQuery.whereClause = "Favorite[user].username='userme'";
Backendless.Persistence.of( "Product" ).find( dataQuery, async )

I don’t understand. Could you provide me with a complete query, please?