Skip to content

Commit

Permalink
fix; correctly handle changes in update hook (Fix #3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 9, 2015
1 parent 5e58d83 commit fae7c94
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -1875,21 +1875,21 @@ function convertSortToArray(opts) {
}

/**
* Internal helper for update
* Internal thunk for .update()
*
* @param {Object} castedQuery
* @param {Object} castedDoc the update command
* @param {Object} options
* @param {Function} callback
* @return {Query} this
* @see Model.update #model_Model.update
* @api private
*/
Query.prototype._execUpdate = function(castedQuery, castedDoc, options, callback) {
Query.prototype._execUpdate = function(callback) {
var schema = this.model.schema;
var doValidate;
var _this;

var castedQuery = this._conditions;
var castedDoc = this._update;
var options = this.options;

if (this._castError) {
callback(this._castError);
return this;
Expand Down Expand Up @@ -2088,7 +2088,7 @@ Query.prototype.update = function(conditions, doc, options, callback) {

// Hooks
if (callback) {
return this._execUpdate(castedQuery, castedDoc, options, callback);
return this._execUpdate(callback);
}

return Query.base.update.call(this, castedQuery, castedDoc, options, callback);
Expand Down

0 comments on commit fae7c94

Please sign in to comment.