Save the instance even the callback is not present

This commit is contained in:
Raymond Feng 2014-08-20 14:22:47 -07:00
parent b9c8018ca0
commit af329e3a66
1 changed files with 6 additions and 6 deletions

View File

@ -1594,7 +1594,9 @@ RelationDefinition.embedsOne = function (modelFrom, modelTo, params) {
opts.default = function() { return new modelTo(); };
} else if (typeof params.default === 'object') {
opts.default = (function(def) {
return function() { return new modelTo(def); };
return function() {
return new modelTo(def);
};
}(params.default));
}
@ -1716,11 +1718,9 @@ EmbedsOne.prototype.destroy = function (cb) {
var modelInstance = this.modelInstance;
var propertyName = this.definition.keyFrom;
modelInstance.unsetAttribute(propertyName, true);
if (typeof cb === 'function') {
modelInstance.save(function(err) {
cb(err);
modelInstance.save(function (err, result) {
cb && cb(err, result);
});
}
};
RelationDefinition.embedsMany = function embedsMany(modelFrom, modelTo, params) {