Not strict equal for scoped find, trigger beforeUpdate with data
This commit is contained in:
parent
40b4d28a1a
commit
8dafb424ed
|
@ -441,7 +441,7 @@ AbstractClass.prototype.save = function (options, callback) {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, data);
|
||||
} else {
|
||||
inst.constructor.create(inst, function (err) {
|
||||
saveDone.call(inst, function () {
|
||||
|
@ -577,11 +577,17 @@ AbstractClass.prototype.updateAttributes = function updateAttributes(data, cb) {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, data);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
AbstractClass.prototype.fromObject = function (obj) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
this[key] = obj[key];
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks is property changed based on current property and initial value
|
||||
*
|
||||
|
@ -652,7 +658,7 @@ AbstractClass.hasMany = function hasMany(anotherClass, params) {
|
|||
function find(id, cb) {
|
||||
anotherClass.find(id, function (err, inst) {
|
||||
if (err) return cb(err);
|
||||
if (inst[fk] === this.id) {
|
||||
if (inst[fk] == this.id) {
|
||||
cb(null, inst);
|
||||
} else {
|
||||
cb(new Error('Permission denied'));
|
||||
|
|
|
@ -16,7 +16,7 @@ Hookable.afterUpdate = null;
|
|||
Hookable.beforeDestroy = null;
|
||||
Hookable.afterDestroy = null;
|
||||
|
||||
Hookable.prototype.trigger = function trigger(actionName, work) {
|
||||
Hookable.prototype.trigger = function trigger(actionName, work, data) {
|
||||
var capitalizedName = capitalize(actionName);
|
||||
var afterHook = this.constructor["after" + capitalizedName];
|
||||
var beforeHook = this.constructor["before" + capitalizedName];
|
||||
|
@ -29,7 +29,7 @@ Hookable.prototype.trigger = function trigger(actionName, work) {
|
|||
beforeHook.call(inst, function () {
|
||||
// actual action also have one param: callback
|
||||
work.call(inst, next);
|
||||
});
|
||||
}, data);
|
||||
} else {
|
||||
work.call(inst, next);
|
||||
}
|
||||
|
|
|
@ -287,7 +287,8 @@ function getConfigurator(name, opts) {
|
|||
* Each validation can add errors to `obj.errors` collection.
|
||||
* If collection is not blank, validation failed.
|
||||
*
|
||||
* @warning This method can be called as sync only when no async validation configured. It's strongly recommended to run all validations as asyncronous.
|
||||
* @warning This method can be called as sync only when no async validation
|
||||
* configured. It's strongly recommended to run all validations as asyncronous.
|
||||
*
|
||||
* @param {Function} callback called with (valid)
|
||||
* @return {Boolean} true if no async validation configured and all passed
|
||||
|
|
Loading…
Reference in New Issue