-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually populated documents get saved as strings instead of ObjectId
s in combination with SchemaType getter
#14759
Closed
2 tasks done
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
vkarpov15
added
the
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
label
Jul 23, 2024
vkarpov15
added a commit
that referenced
this issue
Jul 26, 2024
fix(model+document): avoid depopulating manually populated doc as getter value
2 tasks
This was referenced Aug 21, 2024
This was referenced Aug 21, 2024
This was referenced Sep 24, 2024
This was referenced Sep 25, 2024
This was referenced Sep 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
8.5.1
Node.js version
20.15.1
MongoDB server version
7.0.12
Typescript version (if applicable)
No response
Description
I use a SchemaType getter on
ObjectId
because I think strings are more convenient to work with than ObjectIds.Their use is described and mentioned here:
Have a look at the code snippet below. I cannot query for a pet anymore, given its owner.
I think that is because
pet.save()
unexpectedly saved the owner id as a string into the mongoDB instead of anObjectId
.Steps to Reproduce
Expected Behavior
I expect my
reloadAttempts
to not be allnull
.Also the ObjectId getter should not change the mongoDB data structure.
The text was updated successfully, but these errors were encountered: