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(type): pre hook with deleteOne should resolve this as Query #12642

Merged
merged 1 commit into from Nov 2, 2022

Conversation

lpizzinidev
Copy link
Contributor

fix #12622

Summary
The problem was that the pre and post hook were resolving the method as Document instead of a Query for the conflicting types declared in

type MongooseDocumentMiddleware = 'validate' | 'save' | 'remove' | 'updateOne' | 'deleteOne' | 'init';
type MongooseQueryMiddleware = 'count' | 'estimatedDocumentCount' | 'countDocuments' | 'deleteMany' | 'deleteOne' | 'distinct' | 'find' | 'findOne' | 'findOneAndDelete' | 'findOneAndRemove' | 'findOneAndReplace' | 'findOneAndUpdate' | 'remove' | 'replaceOne' | 'update' | 'updateOne' | 'updateMany';

By changing the type declaration the hook now resolves this as a query by default.

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Nov 2, 2022
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.7.2 milestone Nov 2, 2022
@vkarpov15 vkarpov15 merged commit 8b0adf5 into Automattic:master Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot access to the Model<> on deleteOne pre hook
3 participants