Code cleanup in updateAll/deleteAll

Rename the second callback argument to `info` to make its purpose more
clear. Fix jsdoc comments, note that these comments are NOT shown
on http://apidocs.strongloop.com/.
This commit is contained in:
Miroslav Bajtoš 2015-03-26 19:01:25 +01:00
parent b5188a5af4
commit a70a1b255a
1 changed files with 7 additions and 7 deletions

View File

@ -1302,7 +1302,7 @@ DataAccessObject.findOne = function findOne(query, options, cb) {
* *
* @param {Object} [where] Optional object that defines the criteria. This is a "where" object. Do NOT pass a filter object. * @param {Object} [where] Optional object that defines the criteria. This is a "where" object. Do NOT pass a filter object.
* @param {Object) [options] Options * @param {Object) [options] Options
* @param {Function} [cb] Callback called with (err) * @param {Function} [cb] Callback called with (err, info)
*/ */
DataAccessObject.remove = DataAccessObject.deleteAll = DataAccessObject.destroyAll = function destroyAll(where, options, cb) { DataAccessObject.remove = DataAccessObject.deleteAll = DataAccessObject.destroyAll = function destroyAll(where, options, cb) {
var connectionPromise = stillConnecting(this.getDataSource(), this, arguments); var connectionPromise = stillConnecting(this.getDataSource(), this, arguments);
@ -1375,16 +1375,16 @@ DataAccessObject.remove = DataAccessObject.deleteAll = DataAccessObject.destroyA
} }
function done(err, data) { function done(err, info) {
if (err) return cb(err); if (err) return cb(err);
if (options.notify === false) { if (options.notify === false) {
return cb(err, data); return cb(err, info);
} }
var context = { Model: Model, where: where, hookState: hookState }; var context = { Model: Model, where: where, hookState: hookState };
Model.notifyObserversOf('after delete', context, function(err) { Model.notifyObserversOf('after delete', context, function(err) {
cb(err, data); cb(err, info);
if (!err) if (!err)
Model.emit('deletedAll', whereIsEmpty(where) ? undefined : where); Model.emit('deletedAll', whereIsEmpty(where) ? undefined : where);
}); });
@ -1631,7 +1631,7 @@ DataAccessObject.prototype.save = function (options, cb) {
* @param {Object} [where] Search conditions (optional) * @param {Object} [where] Search conditions (optional)
* @param {Object} data Changes to be made * @param {Object} data Changes to be made
* @param {Object} [options] Options for update * @param {Object} [options] Options for update
* @param {Function} cb Callback, called with (err, count) * @param {Function} cb Callback, called with (err, info)
*/ */
DataAccessObject.update = DataAccessObject.update =
DataAccessObject.updateAll = function (where, data, options, cb) { DataAccessObject.updateAll = function (where, data, options, cb) {
@ -1710,13 +1710,13 @@ DataAccessObject.updateAll = function (where, data, options, cb) {
} }
var connector = Model.getDataSource().connector; var connector = Model.getDataSource().connector;
connector.update(Model.modelName, where, data, function(err, count) { connector.update(Model.modelName, where, data, function(err, info) {
if (err) return cb (err); if (err) return cb (err);
var context = { var context = {
Model: Model, where: where, data: data, hookState: hookState Model: Model, where: where, data: data, hookState: hookState
}; };
Model.notifyObserversOf('after save', context, function(err, ctx) { Model.notifyObserversOf('after save', context, function(err, ctx) {
return cb(err, count); return cb(err, info);
}); });
}); });
} }