Fix updateAttributes impl

See https://github.com/strongloop/loopback-connector-mysql/issues/40
This commit is contained in:
Raymond Feng 2014-06-20 21:13:10 -07:00
parent 2654360532
commit 0a62bffafb
1 changed files with 5 additions and 3 deletions

View File

@ -334,13 +334,15 @@ SqlConnector.prototype.count = function count(model, callback, where) {
* @param {Object} data The model data instance containing all properties to be updated
* @param {Function} cb The callback function
*/
SqlConnector.prototype.updateAttributes = function updateAttrs(model, id, data, cb) {
SqlConnector.prototype.updateAttributes = function updateAttributes(model, id, data, cb) {
if (!isIdValuePresent(id, cb)) {
return;
}
var idName = this.getDataSource(model).idName(model);
data[idName] = id;
this.save(model, data, cb);
delete data[idName];
var where = {};
where[idName] = id;
this.updateAll(model, where, data, cb);
};
/**