Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4412

Investigate NODE-4411 - Add option to throw error when no results are found

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Not Needed

      NODE-4411 Description

      How are you using Mongo? What version of the server and driver are you using? Node.js v18.5.0 running MongoDB v4.7.0

      What is the feature/improvement you would like?

      I'd like to see an option added to the client constructor that would let us choose whether we want the application to throw an error when making a call to the DB and not finding any results. This would work on findOne, updateOne and deleteOne, as well as find, updateMany and deleteMany. There would also be an option on each one of these requests that would override the client option when provided so we can choose to throw an error on specific requests but not all, or vice-versa. For bulkWrite requests, it could throw if at least one of the requests fails.

      What use case would this feature/improvement enable? 

      This would be useful for situations where your code absolutely needs to find that DB element and would help us identify issues when it can't. It would also help to remove `|null` from findOne typings as we'd be sure the request either succeeds or fails, never returns null.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: