BSON ObjectId is not compatible with Types.ObjectId #13712
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
typescript
Types or Types-test related issue / Pull Request
Milestone
Prerequisites
Mongoose version
6.11.5
Node.js version
18.13.0
MongoDB server version
4.16.0
Typescript version (if applicable)
4.9.5
Description
I see the same issue #12537 , and someone fixed it with #13515 on v7.4.0, but not on v6.x.
Since v6.0.0 produced this bug(commit link), why not fix it on v6.x? It's more difficult to migrate to v7.x.
Steps to Reproduce
it's in the description above, or see the same bug issue #12537
Expected Behavior
Fix it on v6.x and suggestions:
Suggestion 1: Back to the original definition
Removing the

_id
property may not be a good thing:Source code(code link):

The original definition(commit link) seems more reasonable, and it's compatible with bson.ObjectId:

Suggestion 2: Removing the magic
_id
onTypes.ObjectId
That's convenience for people using
populate
, but that's not friendly to people usingTypes.ObjectId
andbson.ObjectId
, too confusing.There may be another way to make it happen on
populate
, but modifying the base ObjectId, sounds not to be a good idea.The text was updated successfully, but these errors were encountered: