Parse Cloud request array contains value
I have a parsing data model like ...
Parent
------
children - Array of pointers to Child objects
I am trying to create a query that says ...
Find all parents where the child array contains a specific child object.
This is in contrast to this feature from 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.
Everything players
that is playerName
contained in the given array will be found here .
I need this, but I want to give the value and this value in the array for the key.
I imagine something like ...
query.contains("children", someChildObject);
but the docs for contains
show that it only works under substrings of strings.
How can I do what I am looking for?
source to share
You must use query.equalTo
for a key with an array type.
Try the following queries:
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);
...
source to share