Skip to content

Commit

Permalink
docs(query): clarify that orFail() with updateX() throws if no do…
Browse files Browse the repository at this point in the history
…cument updated, not if no document found

Re: #11620
  • Loading branch information
vkarpov15 committed May 6, 2022
1 parent 474dcdf commit 38c6fe1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -4610,7 +4610,10 @@ Query.prototype.transform = function(fn) {
* // Throws if no doc returned
* await Model.findOne({ foo: 'bar' }).orFail();
*
* // Throws if no document was updated
* // Throws if no document was updated. Note that `orFail()` will still
* // throw if the only document that matches is `{ foo: 'bar', name: 'test' }`,
* // because `orFail()` will throw if no document was _updated_, not
* // if no document was _found_.
* await Model.updateOne({ foo: 'bar' }, { name: 'test' }).orFail();
*
* // Throws "No docs found!" error if no docs match `{ foo: 'bar' }`
Expand Down

0 comments on commit 38c6fe1

Please sign in to comment.