-
-
Notifications
You must be signed in to change notification settings - Fork 4k
types(models): support Mongoose query casting in AnyBulkWriteOperation filter property #15918
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes query casting support for the filter property in bulk write operations, addressing an issue introduced in PR #15820. The fix explicitly overwrites the filter property type to use Mongoose's QueryFilter<TSchema> instead of the MongoDB driver's filter type.
- Modifies type definitions for bulk write operation models to use
QueryFilter<TSchema>for better type safety - Updates
ReplaceOneModel,UpdateOneModel,UpdateManyModel,DeleteOneModel, andDeleteManyModeltypes - Adds a type test demonstrating the fix for
updateOnewithQueryFilter
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| types/models.d.ts | Updates all bulk write operation model types (ReplaceOneModel, UpdateOneModel, UpdateManyModel, DeleteOneModel, DeleteManyModel) to use Omit and override the filter property with QueryFilter<TSchema> for proper Mongoose query casting support |
| test/types/models.test.ts | Adds test function gh15910 demonstrating that QueryFilter<FooType> can be used as a filter in bulk write operations, specifically testing the updateOne operation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AbdelrahmanHafez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@AbdelrahmanHafez I'll need to backport this to 7.x and 8.x you're right. I'll merge this into master and see if I can cherry-pick it. |
Fix #15910
Summary
The work to consolidate
UpdateOneModel, etc. in #15820 unfortunately broke query casting forfilterin bulk write operations. This PR explicitly overwrites thefilterproperty to allow Mongoose castingExamples