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

feat(model): add hydrate option to Model.watch() to automatically hydrate fullDocument #12121

Merged
merged 1 commit into from Jul 26, 2022

Conversation

vkarpov15
Copy link
Collaborator

Fix #11936

Summary

Automatically hydrate fullDocument if hydrate: true is set, but only if you call Model.watch(). Connection.prototype.watch() doesn't support hydrate: true.

Helpful because 1) it might be hard to figure out what function you need to call to init a Mongoose document without setting anything modified or firing setters, 2) this makes it easier for us to add a global hydrateFullDocument option so we can do this on all Model.watch() calls by default.

Examples


let maybePromise = this.driverChangeStream.next(cb);
if (maybePromise && typeof maybePromise.then === 'function') {
maybePromise = maybePromise.then(data => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Smart usage of promises right there.

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! 👍

@vkarpov15 vkarpov15 merged commit f62cf52 into 6.5 Jul 26, 2022
@AbdelrahmanHafez AbdelrahmanHafez deleted the vkarpov15/gh-11936 branch July 26, 2022 17:01
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.

None yet

3 participants