Skip to content

Conversation

vkarpov15
Copy link
Collaborator

Fix #14759

Summary

When depopulating, it looks like Mongoose applies _id getters, which is problematic if you add a default getter to convert all ObjectIds to strings like here: https://thecodebarbarian.com/whats-new-in-mongoose-54-global-schematype-configuration.html#schematype-getters. Fixed by replacing doc._id with doc._doc._id to get the raw id and bypass any getters.

We should backport this to 7.x and 6.x. Same issue impacts those versions.

Examples

@vkarpov15 vkarpov15 added this to the 8.5.2 milestone Jul 23, 2024
Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor style suggestion and would like to see the question above resolved

@vkarpov15 vkarpov15 merged commit 93684f8 into master Jul 26, 2024
@hasezoey hasezoey deleted the vkarpov15/gh-14759 branch July 27, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Manually populated documents get saved as strings instead of ObjectIds in combination with SchemaType getter
4 participants