Skip to content

Commit 4d4dfa1

Browse files
committed
fix(update): make upsert option consistently handle truthy values, not just booleans, for updateOne()
Fix #5839
1 parent 5e279f4 commit 4d4dfa1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/query.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,10 @@ Query.prototype._optionsForExec = function(model) {
11831183
options.readPreference = model.schema.options.read;
11841184
}
11851185

1186+
if (options.upsert !== void 0) {
1187+
options.upsert = !!options.upsert;
1188+
}
1189+
11861190
return options;
11871191
};
11881192

test/model.update.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2840,7 +2840,7 @@ describe('model: update:', function() {
28402840
name: String
28412841
});
28422842

2843-
var Model = db.model('gh3677', schema);
2843+
var Model = db.model('gh5839', schema);
28442844

28452845
var opts = { upsert: 1 };
28462846
Model.update({ name: 'Test' }, { name: 'Test2' }, opts, function(error) {

0 commit comments

Comments
 (0)