-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Milestone
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.18.1
Node.js version
22.16.0
MongoDB server version
8
Typescript version (if applicable)
No response
Description
A change made to the definition of MongoBaseQueryOptions
in this PR for 8.17 seems to have inadvertently left out the ability to pass arbitrary options into various model methods. Some methods use QueryOption which does allow arbitrary options while many others, like countDocuments, use MongoBaseQueryOptions which no longer allows arbitrary options.
Suggested change to MongooseBaseQueryOptions:
type MongooseBaseQueryOptions<DocType = unknown> = Pick<QueryOptions<DocType>, MongooseBaseQueryOptionKeys> & {
[other: string]: any;
};
Steps to Reproduce
Usage code:
type OurCustomOptionsWhereWeHavePreHooksSetupToHandle {
includeDeleted?: boolean;
}
...
this.model
.countDocuments(filter, {
includeDeleted: options?.includeDeleted ?? false,
});
includeDeleted
is no longer allowed.
Object literal may only specify known properties, and 'includeDeleted' does not exist in type 'CountOptions & MongooseBaseQueryOptions<TReadEntity> & Abortable'.ts(2353)
Expected Behavior
We should be able to pass arbitrary options into various model query method.
Metadata
Metadata
Assignees
Labels
No labels