Skip to content

Commit 73de49c

Browse files
committedNov 9, 2015
fix; proper support for .update(doc) (Fix #3221)
1 parent b5329a1 commit 73de49c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎lib/query.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1989,20 +1989,27 @@ Query.prototype._execUpdate = function(castedQuery, castedDoc, options, callback
19891989

19901990
Query.prototype.update = function(conditions, doc, options, callback) {
19911991
if ('function' === typeof options) {
1992-
// Scenario: update(conditions, doc, callback)
1992+
// .update(conditions, doc, callback)
19931993
callback = options;
19941994
options = null;
19951995
} else if ('function' === typeof doc) {
1996-
// Scenario: update(doc, callback);
1996+
// .update(doc, callback);
19971997
callback = doc;
19981998
doc = conditions;
19991999
conditions = {};
20002000
options = null;
20012001
} else if ('function' === typeof conditions) {
2002+
// .update(callback)
20022003
callback = conditions;
20032004
conditions = undefined;
20042005
doc = undefined;
20052006
options = undefined;
2007+
} else if (typeof conditions === 'object' && !doc && !options && !callback) {
2008+
// .update(doc)
2009+
doc = conditions;
2010+
conditions = undefined;
2011+
options = undefined;
2012+
callback = undefined;
20062013
}
20072014

20082015
// make sure we don't send in the whole Document to merge()

0 commit comments

Comments
 (0)
Please sign in to comment.