Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Fix #14935

Summary

insertMany() currently respects schema-level flattenObjectIds option settings, which means if schema sets flattenObjectIds: true then Mongoose will store ObjectIds as strings.

This does not affect save() because save() was fixed in #13648, but that issue still affects insertMany().

In general, internalToObjectOptions should always set flattenObjectIds to true because we rely on those options when trying to get the MongoDB server representation of an object for queries, insertMany(), etc.

We should also backport this fix to 6.x and 7.x.

Examples

@vkarpov15 vkarpov15 added this to the 8.7.1 milestone Oct 6, 2024
@vkarpov15 vkarpov15 modified the milestones: 8.7.1, 8.7.2 Oct 8, 2024
vkarpov15 and others added 2 commits October 9, 2024 11:22
@vkarpov15 vkarpov15 modified the milestones: 8.7.2, 8.7.1 Oct 9, 2024
@vkarpov15 vkarpov15 merged commit d861d21 into master Oct 9, 2024
57 of 58 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-14935 branch October 9, 2024 15:25
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.

find on ObjectIds not working after insertMany

3 participants