HI is there any way to run a trigger eg beforeSave (_User) in certain cases, not every time I update User. I would like to decide when the trigger should be fired, is there any way?
Triggers will always fire, but you can program the function only on certain events.
Parse.Cloud.beforeSave(Parse.User, ({object, master, context}) => {
if (!object.existed()) {
// this will only fire on signups
}
if (object.dirty("key")) {
// this will only fire if key is updated
}
if (context.key) {
// this will only fire if context.key is passed
}
});
And to pass context:
User.save(null, { context: { key: true } })
4 Likes
However, you can do this by overriding the trigger functions.