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

Investigate NODE-4134 - Wrong TS type for upsertedId (can be null)

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed

      NODE-4134 Description

      What problem are you facing?

      updateOne returns a null upsertedId (but doc and TS type do not allow that).

      What driver and relevant dependency versions are you using?

      mongodb@4.4.1

      Steps to reproduce?

      Just look at the code: https://github.com/mongodb/node-mongodb-native/blob/5132bc9d8ba816b0d98e1fceb6dfc96be0beb1da/src/operations/update.ts#L174

       

      Btw you should refactor your code, you should not have been able to return a null value for a non nullable field. You should remove Document from callback arg union type or at least check that the value you give to the callback match UpdateResult type.

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: