Skip to content

Commit 610a146

Browse files
authored
Merge pull request Automattic#15126 from Automattic/vkarpov15/updateone-null
fix(model): avoid throwing unnecessary error if `updateOne()` returns `null` in `save()`
2 parents 682160f + 6b3241f commit 610a146

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,11 @@ Model.prototype.$__handleSave = function(options, callback) {
388388

389389
this[modelCollectionSymbol].updateOne(where, update, saveOptions).then(
390390
ret => {
391-
ret.$where = where;
391+
if (ret == null) {
392+
ret = { $where: where };
393+
} else {
394+
ret.$where = where;
395+
}
392396
callback(null, ret);
393397
},
394398
err => {

0 commit comments

Comments
 (0)