Reputation: 1226
If I try to filter the data by using containedIn
as below I will be getting empty result because I'm trying to filter from pointer column type userProfile
despite that I include the userProfile
in the query.
However, I tried to use containedIn
directly to another array column in User
and seems it was working fine. is this kind of the below queries will not work? and what could be the alternative solutions?
const query = new Parse.Query('User');
query.equalTo('accountType', 'Student');
query.include('userProfile');
// search.subjects is an array
query.containedIn('userProfile.subjectsIds', search.subjects);
Upvotes: 0
Views: 283
Reputation: 21
A "little bit" late, but it is absolutely possible. To see examples using query (like you want to), have a look here, starting on line 595:
Easiest way of finding examples is going through tests in the parse repo, at least for me.
If you want to do this in the aggregation pipeline, just use $match stage with $in, like below, where <column_name> is the name of the pointer column, ids is an array of ids and table_name is the table you point to. The $ sign and _p_ are there because of how parse works and are necessary.
{
$match: {
_p_<column_name>: { "$in": ids.map((id) => "table_name$"+id)}
}
}
I think it is also very instructive to play with MongoDB console.
Upvotes: 0
Reputation: 3090
Unfortunately, you can't perform containedIn() on included objects. For containedIn() to work it has to be performed on a column of the class you are querying.
So in other words, you will have to perform this query directly on the userProfile class for containedIn() to work
Upvotes: 0