-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
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)
- depends on
-
NODE-3855 Investigate NODE-3854 - _id field missing in some collection functions
- Closed