javascript - 解析云查询数组包含值

标签 javascript parse-platform

我有一个解析数据模型...

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);
...

引用。 Queries on Array Values

关于javascript - 解析云查询数组包含值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27001619/

相关文章:

javascript - 如何使用 promise 检查错误?

javascript - 在没有 execCommand 的情况下在 contenteditable div 中添加或修改文本/内容?

在 iframe 中使用替换方法的 Javascript

javascript - 如何访问每个键具有多个值的 JSON 对象?

javascript - 解析云代码替代方案

swift - 如何在 Parse.com 和 swift 中使用自定义用户列

ios - 解析.com : saveInBackgroundWithBlock - block not called

javascript - ADSafe 和 JSLint 的问题

node.js - 如何获取当前用户的sessionToken?

javascript - 操作顺序解析云