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

Update docs to include the section about populating multiple paths in middleware #11177

Merged
merged 2 commits into from Jan 9, 2022

Conversation

aleksadjukic
Copy link
Contributor

Added a section that explains how to populate multiple paths in middleware.

Summary

This is a pretty common use case, yet it is not really straight forward to achieve, so I believe that the solution to the problem should definitely be in the documentation.

Added a section that explains how to populate multiple paths in middleware.
@aleksadjukic aleksadjukic changed the title Update populate.md Update docs to include the section about populating multiple paths in middleware Jan 6, 2022
Populating multiple paths in middleware is just a little bit trickier than what you may think. Here's how you may expect it to work:

```javascript
userSchema.pre('find', function (next) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be great to add the schema definition to this example: it isn't clear that followers and following reference User

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, will do :)

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@vkarpov15 vkarpov15 added this to the 6.1.6 milestone Jan 9, 2022
@vkarpov15 vkarpov15 added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Jan 9, 2022
@vkarpov15 vkarpov15 merged commit dff2d49 into Automattic:master Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants