I need to query my Parse.com backend for a list of objects, that have a list of pointers within those objects.
Given a pointer value, how can I query for a list of objects whose inner list of pointers contains that pointer value?
Some more detail, ObjectA contains a list of pointers, to ObjectB. When I delete ObjectB, I have cloud code that cascades this deletion. I need to query all of my ObjectA's that have ObjectB in their list of ObjectB's.
I hope this makes sense.
I have been looking at the "contain" methods for the Javascript API; Do these methods also work with keys that are arrays?
My current beforeDelete implementation is as follows.
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);
}
);
This code seems inefficient as its querying a ton of unnecessary ObjectA's that may not even have a pointer in their list of ObjectB's.