Some middleware does not have access to operation options #13633
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
typescript
Types or Types-test related issue / Pull Request
Milestone
Prerequisites
Mongoose version
7.4.0
Node.js version
16.19.1
MongoDB server version
5
Typescript version (if applicable)
4.8.3
Description
It is not possible to access the operation options in the following middleware functions:
I know that the pre middlewares of the above operations do in fact get a reference to the options object supplied by the client. Unfortunately, these objects are not included in the type definitions of the middleware functions, so it is not possible to access them without overriding the types.
Steps to Reproduce
Same with post updateOne, pre/post deleteOne, post insertMany
Expected Behavior
Ideally I'd like to be able to always access operation options like this can be done with query / aggregation middleware:
I understand that this might not be possible with Document middleware, in which case it would be nice to receive the options as the last argument to the middleware. Matter of fact, this is already the case, only the types do not reflect that.
The text was updated successfully, but these errors were encountered: