我有一个解析数据模型...
Parent
------
children - Array of pointers to Child objects
我正在尝试创建一个查询...
Find all Parents where the children array contains the specific Child object.
这与文档中的这个功能有点相反。
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.
这将找到给定数组中包含 playerName
的所有 players
。
我想要这个,但我想给出一个值,并且该值位于键的数组中。
我想这就像...
query.contains("children", someChildObject);
但是 contains
的文档显示它只适用于字符串的子字符串。
我将如何做我正在寻找的东西?
最佳答案
对于数组类型的键,您应该使用 query.equalTo
。
尝试如下查询:
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);
...
关于javascript - 解析云查询数组包含值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27001619/