Do not do any setup for beforeSave trigger if none is set for this className.

This commit is contained in:
Nikita Lutsenko
2016-02-24 00:05:03 -08:00
parent 1ae61c92c8
commit b477d16992
2 changed files with 10 additions and 0 deletions

View File

@@ -111,6 +111,11 @@ RestWrite.prototype.validateSchema = function() {
// Runs any beforeSave triggers against this operation.
// Any change leads to our data being mutated.
RestWrite.prototype.runBeforeTrigger = function() {
// Avoid doing any setup for triggers if there is no 'beforeSave' trigger for this class.
if (!triggers.triggerExists(this.className, triggers.Types.beforeSave)) {
return Promise.resolve();
}
// Cloud code gets a bit of extra data for its objects
var extraData = {className: this.className};
if (this.query && this.query.objectId) {