Reputation: 77641
I have a parse data model like...
Parent
------
children - Array of pointers to Child objects
I'm trying to create a query that says...
Find all Parents where the children array contains the specific Child object.
It's sort of the opposite of this function from the docs.
query.containedIn("playerName", ["Jonathan Walsh", "Dario Wunsch", "Shawn Simon"]);
// note you can also do this with object pointers which is EXACTLY opposite to what I want.
This will find all the players
where the playerName
is contained in the given array.
I want this but I want to give a value and that value to be in the array for the key.
I imagine it's something like...
query.contains("children", someChildObject);
but the docs for contains
shows it only works for substrings of strings.
How would I do what I'm looking for?
Upvotes: 3
Views: 2766
Reputation: 813
You should use query.equalTo
for key with an array type.
Try query like following:
var ChildClass = Parse.Object.extend('ChildClass');
var childObj = new ChildClass();
childObj.id = 'objId';
// you don't need to do above if you already have the object.
query.equalTo("children", childObj);
...
Upvotes: 3