Skip to content

Conversation

@vkarpov15
Copy link
Collaborator

Fix #15910

Summary

The work to consolidate UpdateOneModel, etc. in #15820 unfortunately broke query casting for filter in bulk write operations. This PR explicitly overwrites the filter property to allow Mongoose casting

Examples

@vkarpov15 vkarpov15 added this to the 9.0.3 milestone Dec 24, 2025
Copilot AI review requested due to automatic review settings December 24, 2025 21:23
Copy link
Contributor

Copilot AI left a 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, and DeleteManyModel types
  • Adds a type test demonstrating the fix for updateOne with QueryFilter

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.

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

Is this PR meant to target 7.x? Because #15820 targeted #15789 which targeted 7.x.
The 9.x version of this is #15819 which only added the overwriteImmutable option to TS, didn't change much else in the TS types structure.

@vkarpov15 vkarpov15 modified the milestones: 9.0.3, 9.1 Dec 29, 2025
@vkarpov15
Copy link
Collaborator Author

@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.

@vkarpov15 vkarpov15 merged commit e782cb6 into master Dec 29, 2025
11 checks passed
vkarpov15 added a commit that referenced this pull request Dec 29, 2025
…n filter property (#15918)

* types(models): support Mongoose query casting in AnyBulkWriteOperation filter property

Fix #15910

* remove stray comment
vkarpov15 added a commit that referenced this pull request Dec 29, 2025
@AbdelrahmanHafez AbdelrahmanHafez deleted the vkarpov15/gh-15910 branch December 30, 2025 12:20
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.

QueryFilter is not assignable to filter part of AnyBulkWriteOperation

3 participants