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

docs(typescript): clarify that setting THydratedDocumentType on schemas is necessary for correct method context #14575

Merged
merged 4 commits into from
May 9, 2024

Conversation

vkarpov15
Copy link
Collaborator

Summary

#14573 points out that, if following Mongoose's docs on subdocuments in TypeScript, you end up with incorrect this param for methods. That's because you also need to set THydratedDocumentType on Schema<> as well as Model<> to get correct context for methods and middleware.

Examples

@vkarpov15 vkarpov15 added this to the 8.3.5 milestone May 7, 2024
docs/typescript/schemas.md Outdated Show resolved Hide resolved
@hasezoey hasezoey added docs This issue is due to a mistake or omission in the mongoosejs.com documentation typescript Types or Types-test related issue / Pull Request labels May 7, 2024
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit d5202fb into master May 9, 2024
3 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14573 branch May 9, 2024 15:18
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 typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants