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

types(model): make bulkWrite() types more flexible to account for casting #14423

Merged
merged 6 commits into from Mar 11, 2024

Conversation

vkarpov15
Copy link
Collaborator

Re: #14400

Summary

Bringing MongoDB's AnyBulkWriteOperation type into Mongoose, and overriding update with Mongoose's UpdateQuery type to account for query casting. Currently, the issue is that bulkWrite([{ updateOne: { $set: { date: '2023-06-01' } } }]) fails type checks because date needs to be of type date. And passing in AnyKeys<> is a no-go because that messes up MongoDB's $addToSet type checking and makes the bulkWriteAddToSet test in models.test.ts fail

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

I think the changes look good aside from some minor nit-picks. Maybe also consider adding the update no casting warning to the typescript types

lib/model.js Outdated Show resolved Hide resolved
types/models.d.ts Outdated Show resolved Hide resolved
@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Mar 8, 2024
vkarpov15 and others added 2 commits March 8, 2024 17:14
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 requested a review from hasezoey March 8, 2024 22:16
lib/model.js Outdated Show resolved Hide resolved
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit 3ba9778 into master Mar 11, 2024
37 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14400 branch March 11, 2024 14:29
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.

None yet

2 participants