Error deleting object in destroyAll file using parsing cloud code

I am trying to cascade delete all subobjects contained in an array of pointers when a parent object is deleted, but I am getting an error.

This is my code:

Parse.Cloud.beforeDelete("Parent", function(request, response) {
var children = request.object.get("children");
Parse.Object.destroyAll(children, {
    success: function() {
        response.success();
    },
    error: function(error) {
        console.error("Error deleting related children " + error.code + ": " + error.message);
        response.error(error);
    }
});

}); As I said, Parent has a children property, which is an array of pointers to Child objects. This is the error I get: "Error deleting related 600 children: error deleting an object in destroyAll"

+3
source share
2 answers

If you add this line:

Parse.Cloud.useMasterKey();

It should work.

+1
source

Parse.Object.destroyAll , . :

<static> Parse.Object.destroyAll(list, options)

, :

Parse.Object.destroyAll([children],{
    success:function(ret):{...},
    error:function(err):{...}
});

Parse.Object.destroyAll

0

All Articles