I have a problem executing some Cloud Code. I am making a To-Do list App where users can create Lists and then add Posts to that list. I have a Class of Posts and a Class of Lists.
I am writing some Cloud Code that I need to delete all the Posts that were associated with the List when the user deletes the List.
My problem is that the code isn't working at all. When a user deletes the List, only the list is deleted and not the related posts. Would anybody be able to spot the probably obvious error I have made in my code? If so I would be very grateful!
Thanks,
Dan
p.s. "listObjectId" is saved as a String in my database
Parse.Cloud.afterDelete("Lists", function(request) {
var objectId = request.object.id;
query = new Parse.Query("Posts");
query.equalTo("listObjectId", objectId);
query.find({
success: function(posts) {
Parse.Object.destroyAll(posts, {
success: function() {},
});
},
});
});