gpt4 book ai didi

javascript - Parse.com Javascript API,查询包含指针列表的对象列表

转载 作者:行者123 更新时间:2023-12-03 08:13:17 25 4
gpt4 key购买 nike

我需要在 Parse.com 后端查询对象列表,这些对象内有一个指针列表。

给定一个指针值,如何查询其内部指针列表包含该指针值的对象列表?

更详细的信息是,ObjectA 包含指向 ObjectB 的指针列表。当我删除 ObjectB 时,我有级联此删除的云代码。我需要查询所有在 ObjectB 列表中包含 ObjectB 的 ObjectA。

我希望这是有道理的。

我一直在研究 Javascript API 的“包含”方法;这些方法也适用于数组键吗?

我当前的 beforeDelete 实现如下。

    var objectB = request.object;
var objectAQuery = new Parse.Query('ObjectA');

objectAQuery.find().then(
function (objectAArray) {
objectAArray.forEach(function (objectA) {
objectA.remove('objectBListKey',objectB);
});
Parse.Object.saveAll(objectAArray, {
success: function () {
response.success();
},
error: function (error) {
response.error(error);
}
});
},
function (error) {
response.error(error);
}
);

这段代码看起来效率很低,因为它查询了大量不必要的 ObjectA,而这些 ObjectA 甚至可能在其 ObjectB 列表中没有指针。

最佳答案

It seems like what you are looking for is the containedIn function on Parse.Query 。这将允许您在指针数组的键上查询 ObjectA 类,仅返回具有您传递到其指针数组的 containedIn 参数中的指针的 ObjectA 实例。

关于javascript - Parse.com Javascript API,查询包含指针列表的对象列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34056732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com