findByIdAndUpdate + .select returns only _id on v >= 6.9.3, < 7.0.0 #13340
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
6.9.3
Node.js version
16
MongoDB server version
4.4
Typescript version (if applicable)
No response
Description
After upgrading to the latest version of mongoose v6.x, I noticed that only the
_id
field was returned from one of my update statements, resulting in errors trying to access data onundefined
subdocuments.In my case, I am using
select("+optionalfield")
, but it seems any projection fails.Result:
Expected result:
I have reproduced this on different versions of mongoose and it seems that v6.9.3 introduced this error.
Upgrading to v7 has fixed it for me, but I guess you might want to release a fix on v6.
Steps to Reproduce
Install mongoose version 6.x and run the following code:
Expected Behavior
The following code
should return:
but instead returns:
The text was updated successfully, but these errors were encountered: