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

[REG 8.0.3->8.0.4/8.1.0] updateOne/updateMany can no longer accept runValidators/new #14275

Closed
2 tasks done
orgads opened this issue Jan 20, 2024 · 3 comments · Fixed by #14278
Closed
2 tasks done

[REG 8.0.3->8.0.4/8.1.0] updateOne/updateMany can no longer accept runValidators/new #14275

orgads opened this issue Jan 20, 2024 · 3 comments · Fixed by #14278

Comments

@orgads
Copy link
Contributor

orgads commented Jan 20, 2024

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

Node.js version

20.10.0

MongoDB server version

6.2.0

Typescript version (if applicable)

5.3.3

Description

Passing runValidators: true to updateOne (documented here) is broken with 8.1.0.

Probably broke with abdac8d.

I think that either updateOne should be reverted to accept QueryOptions, or MongooseQueryOptions should include also runValidators.

Steps to Reproduce

import { Model } from 'mongoose';

export function func(dbModel: Model<unknown>) {
  // Object literal may only specify known properties, and 'runValidators' does not exist in type 'UpdateOptions & Omit<MongooseQueryOptions<unknown>, "lean">'.ts(2353)
  void dbModel.updateOne({ foo: 'bar' }, { foo: 'baz' }, { runValidators: true });
}

Expected Behavior

No response

@orgads orgads changed the title [REG 8.0 -> 8.1] updateOne can no longer accept runValidators [REG 8.0.3->8.0.4/8.1.0] updateOne can no longer accept runValidators Jan 20, 2024
@orgads orgads changed the title [REG 8.0.3->8.0.4/8.1.0] updateOne can no longer accept runValidators [REG 8.0.3->8.0.4/8.1.0] updateOne/updateMany can no longer accept runValidators/new Jan 21, 2024
@par333k
Copy link

par333k commented Jan 22, 2024

The return option for the updateMany option, new, is also broken and cannot be used.

vkarpov15 added a commit that referenced this issue Jan 22, 2024
types(query): add missing `runValidators` back to MongooseQueryOptions
@orgads
Copy link
Contributor Author

orgads commented Jan 22, 2024

Thanks!

@vkarpov15
Copy link
Collaborator

@par333k new isn't a valid option for updateMany(), it is only useful for findOneAndUpdate() findOneAndReplace() etc.

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 a pull request may close this issue.

3 participants