Skip to content

Commit fae7c94

Browse files
committedNov 9, 2015
fix; correctly handle changes in update hook (Fix #3549)
1 parent 5e58d83 commit fae7c94

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎lib/query.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1875,21 +1875,21 @@ function convertSortToArray(opts) {
18751875
}
18761876

18771877
/**
1878-
* Internal helper for update
1878+
* Internal thunk for .update()
18791879
*
1880-
* @param {Object} castedQuery
1881-
* @param {Object} castedDoc the update command
1882-
* @param {Object} options
18831880
* @param {Function} callback
1884-
* @return {Query} this
18851881
* @see Model.update #model_Model.update
18861882
* @api private
18871883
*/
1888-
Query.prototype._execUpdate = function(castedQuery, castedDoc, options, callback) {
1884+
Query.prototype._execUpdate = function(callback) {
18891885
var schema = this.model.schema;
18901886
var doValidate;
18911887
var _this;
18921888

1889+
var castedQuery = this._conditions;
1890+
var castedDoc = this._update;
1891+
var options = this.options;
1892+
18931893
if (this._castError) {
18941894
callback(this._castError);
18951895
return this;
@@ -2088,7 +2088,7 @@ Query.prototype.update = function(conditions, doc, options, callback) {
20882088

20892089
// Hooks
20902090
if (callback) {
2091-
return this._execUpdate(castedQuery, castedDoc, options, callback);
2091+
return this._execUpdate(callback);
20922092
}
20932093

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

0 commit comments

Comments
 (0)
Please sign in to comment.