parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

beforeDelete problem

Open mahabubakram opened this issue 10 years ago • 2 comments

Scenario:

  1. I have created a object via client successfully.
  2. Destroy of that object was also successful via client.
  3. But when I use
Parse.Cloud.beforeDelete("MyClass", function(request){
    console.log("Before delete EXECUTED");
});

then the destroy of that object is not possible. 4. In the console it is printed "Before delete EXECUTED" but the destroy operation from client gives error.

p.s: my server is running in heroku and database is hosted in mongolabs.

mahabubakram avatar Feb 23 '16 13:02 mahabubakram

Hi,

this is the signature of the beforeDelete trigger

Parse.Cloud.beforeDelete("MyClass", function(request, response) {
  // your code here
  response.success(); // do not forget to call response.success() to allow the deletion of your object
});

It seems that you forgot to call response.success(). You have to call it into beforeDelete to allow parse-server to delete your object.

If you want to stop the deletion, you can call response.error(). For example, if the delete operation is not authorized for the user who called it.

Hope it helps.

Kira2 avatar Feb 23 '16 14:02 Kira2

Thanks Kira2. I totally missed that. Thanks a lot.

mahabubakram avatar Feb 23 '16 14:02 mahabubakram