Skip to content
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

fix(populate): handle deselecting _id with array of fields in populate() #14242

Merged
merged 1 commit into from Jan 9, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14231

Summary

We handle deselecting _id in populate() using the following syntax: await U.findOne({ name: 'u1' }).populate('comments', '-_id'); but putting -_id in an array await U.findOne({ name: 'u1' }).populate('comments', ['-_id']); leads to a malformed result document where comments is [ { '0': '-_id' } ] due to how we shallow copy select conditions before removing _id. So we need an additional case to avoid using { ... } to shallow copy an array.

Examples

@vkarpov15 vkarpov15 merged commit 2c2377d into master Jan 9, 2024
34 checks passed
@vkarpov15 vkarpov15 added this to the 8.0.4 milestone Jan 9, 2024
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-14231 branch January 9, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants