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(model+query): handle populate with lean transform that deletes _id #12193

Merged
merged 1 commit into from Aug 3, 2022

Conversation

vkarpov15
Copy link
Collaborator

Fix #12143

Summary

Right now populate doesn't work if you use lean: { transform: function myTransform(doc) { ... } } and myTransform deletes _id. That's because the lean transform runs before populate's _assign() step, and _assign() needs _id (or whatever the foreign field for populate is) to figure out where to put the populated documents.

This is similar to #9175, where we had to also remove the foreign field from the projection, and just delete the projected-out field in memory after _assign().

Examples

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

LGTM, thanks 👍

Copy link
Collaborator

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

LGTM

@vkarpov15 vkarpov15 merged commit 07e36aa into master Aug 3, 2022
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-12143 branch August 3, 2022 01:19
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.

lean transform doesn't work & not return doccument
4 participants