0
votes

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() {},
          });
    },
  });
});
1

1 Answers

0
votes

If I were you I would construct it properly, you got comma but nothing after that... if it doesnt help I would check you class Permissions if the user is able to delete them all or if you should use Masterkey...

Parse.Object.destroyAll(toDelete, { success: function(success) {

        }, error: function(error) {

        }
    });

you can also put some logging to be sure something has been downloaded, and you should also include that log for better debugging...

console.log("Whatever");