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

_id field missing in some collection functions

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.3.1
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed

      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:
            js@stairwage.com Jérôme Senot
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: