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

Investigate NODE-3854 - _id field missing in some collection functions

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

      NODE-3854 Description

      What problem are you facing?

      With last version including "Consistent type inference for the _id type", findOneAndUpdate (and probably many other functions) returns an object not enhanced with WithId<...>, so _id field does not exists in the result if schema has no or optional _id field.

      What driver and relevant dependency versions are you using?

      mongodb@4.3.0

      Steps to reproduce?

      console.log((await ((await getClient()).db('db').collection<{ a: { b: string, c: string }}>('col').findOneAndUpdate({}, { $set: { 'a.b': '' }}))).value?._id);

      => TypeScript error Property '_id' does not exist on type '{ a:

      { b: string; c: string; }

      ; }'.ts(2339)

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            dbeng-pm-bot PM Bot
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: