-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
types(document): add generic param to depopulate() to allow updating properties #14891
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, if i see this correctly, it will now merge the types instead of overwriting? example, instead of PopulatedType
changing to ObjectId
it is now PopulatedType | ObjectId
?
No, |
nevermind, didnt see that in the last |
Fix #14876
Summary
Right now
doc.depopulate()
just returnsthis
, which may be incorrect if paths are depopulated. This PR adds generic parameter, similar to howdoc.populate<{ user: UserType }>('user')
returns document withuser
property updated,doc.depopulate<{ user: ObjectId }>('user')
also updates theuser
property type.Examples