Filter objects in relation list


I’m looking for a solution to filter a list of objects in a relation (one-to-many) based on attribute of many side object.

I have something like

list of B

active: Boolean

I’m trying to retrieve A’s with active B’s using BackendlessDataQuery API in Android Enviroment.


Hi, Wakim!

Did not quite understand your situation. You class A has a list of B instances. and class B has a boolean “active” field. So you want to get those A that have at least one active instance of B?
BTW, did you check BackendlessQuery documentation:

Thanks Anatolii,

English isn’t my main language, so let me elaborate the issue.

Right now, I’m doing a query to fetch all A’s based on a certain criteria. Along with the query, i’m using a QueryOptions to fetch all related B’s for each A.

But I want to filter the related list of B’s for just the active rows, not all B’s. As a workaround I can try to filter it in client-side, but it waste resource specially when the list is big.


Sorry Anatolli, i’ve commented below, instead of replying you :frowning:

Unfortunately, there is no direct way of doing this. You can only search by related objects but cannot retrieve related objects partially - either you retrieve all of the related objects or none of them.

But you can do it this way:

  1. Retrieve A object, read its objectId (let’s call it AobjectId).
  2. Create query for B objects with WhereClause like this: A[rel].id = AobjectId (where “rel” is the name of the relation in A to B objects.
    You can use the documentation links I’ve shared with you in a previous comment for more information on this.

Thanks Anatolli, i’ll take a look into this workaround.