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(document): allow calling $model() with no args for TypeScript #13963

Merged
merged 2 commits into from Oct 12, 2023

Conversation

vkarpov15
Copy link
Collaborator

Fix #13878

Summary

TypeScript doesn't allow specifying a type for the constructor property, so right now there's no ergonomic way to get the model associated with a document in TypeScript. Need to use as. This PR makes it so that you can do doc.$model(). Requires a small runtime change, Mongoose doesn't currently support calling doc.$model() without args.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

LGTM, aside from a somewhat unrelated question

types/document.d.ts Show resolved Hide resolved
@vkarpov15 vkarpov15 merged commit e1d3bfa into master Oct 12, 2023
25 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-13878 branch October 12, 2023 13:07
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.

How to get the model name/collection name from a document middleware?
2 participants