Hi All,
Hopefully a quick one.
I have a table called Bar
, Bar
has a column called openingTimes
which has a 1:N relation to the OpeningTimes
table.
The OpeningTimes table looks like this:
In my query I’m returning all Bars in a certain radius and want to just return a specific OpeningTimes
row for a given day.
At the moment when I run my query it pulls back the Bar
objects and all of their OpeningTimes
rows not just the child I want.
I.e…:
DataQueryBuilder queryBuilder = DataQueryBuilder.create();
String whereClause = "
distanceOnSphere('POINT(-0.10854542936716162 51.51638512966117)', location) < mi(1)
and openingTimes.weekDay = 7";
queryBuilder.addRelated( "information" );
queryBuilder.addRelated("openingTimes");
queryBuilder.setRelationsDepth(1);
queryBuilder.setWhereClause( whereClause );
return Backendless.Data.of( Bar.class ).find( queryBuilder );
I’m guessing this is because I’m using .addRelated("openingTimes")
, so my question is, can I just return that one OpeningTimes
object which is in my where clause? I attempted using queryBuilder.setRelationsPageSize(1);
this did in fact did only pull back one OpeningTimes
object, but it was the wrong one (didn’t care about my where clause).
Please bare in mind that I also need to still return the other addRelated Information
object, but that’s fine as its 1:1.