I have been trying to change the returned properties of a joined object, considering that it has a filter from a WHERE clause. However this was not possible directly because the WHERE clause returns a QueryExpression class and not the Query class that has the returningProperties method.
I tried according to the code below:
var query = Query<Obj1>(context)
..where((o) => o.state).equalTo(state);
query.join(set: (q) => q.objs2)
..where((a) => a.state).equalTo(state)
..returningProperties((a) => [a.id, a.description, a.answer]);
var results = await query.fetch();
I was able to perform the query doing the following:
var query = Query<Obj1>(context)
..where((o) => o.state).equalTo(state);
Query<Obj2> subQuery = query.join(set: (q) => q.objs2)
..where((a) => a.state).equalTo(state)
..returningProperties((a) => [a.id, a.description, a.answer]);
var results = await query.fetch();
My question is, is there another way to do this? What have I done is correct? Is it possible to have a simpler or more direct way of putting these clauses together?