jmk2142
jmk2142

Reputation: 8581

Is there a way to skip a before/after save/delete hook in certain cases?

Question is, is there a way to explicitly run a save/delete, etc. without triggering the established hook? Like a "skipHook" option or something. Example:

// HOOK: beforeDelete

Parse.Cloud.beforeDelete('Thing', function(request, response){ // STUFF // });



// FUNCTION: some other cloud function that will run an alternate delete behavior

Parse.Cloud.define('AltBeforeDeleteThing', function(request, response){
  var id = request.params.id;
  var thing = new Thing();
      thing.id = id;

  thing.destroy().then(function(){ // STUFF // });
  // Is there a way to skip the beforeDelete hook?

}

The destroy() in the cloud function will trigger the beforeDelete hook. But I've run into situations where it'd be nice to have exceptions so I can build alternate behaviors around some of these Ops.

The only way I can think of doing this is creating an if (!master) clause in the beforeDelete hook and using master any time I wanted to skip that code. But it feels like I'm cheating and that it will put me in a corner I can't escape down the road.

What's the correct practice to get around established hooks to define alternate behaviors around these Ops?

Upvotes: 1

Views: 731

Answers (1)

Rohit
Rohit

Reputation: 428

Old question but I'll answer.

Upvotes: 1

Related Questions