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

feat(NODE-6290): add sort option to UpdateOne and ReplaceOne #4229

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aditi-khare-mongoDB
Copy link
Contributor

@aditi-khare-mongoDB aditi-khare-mongoDB commented Sep 10, 2024

Description

Add sort option to UpdateOne and ReplaceOne operations.
Downstream changes for DRIVERS-2822.

What is changing?

If a query in an updateOne/replaceOne operation returns more than one document and the sort operation is provided, the operation will return the document that is first through the sort.

If server < 8.0 and/or the sort option is provided in updateMany/replaceMany, the server will throw an error.

Is there new documentation needed for these changes?

Yes, there are new API docs.

What is the motivation for this change?

See above and support for new server options.

Release Highlight

Add sort option to updateOne() and replaceOne() operations

If the query of a updateOne or replaceOne operation matches multiple documents, and the sort option is provided, the first document matched by the sort order will be updated.

This option is only supported by server versions >= 8.0. Older servers will report an error for using this option. In addition, the server will also report an error if the caller explicitly provides a value with updateMany() or replaceMany().

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@aditi-khare-mongoDB aditi-khare-mongoDB changed the title feat(NODE-6290): Add sort option to UpdateOne feat(NODE-6290): add sort option to UpdateOne Sep 10, 2024
@aditi-khare-mongoDB aditi-khare-mongoDB changed the title feat(NODE-6290): add sort option to UpdateOne feat(NODE-6290): add sort option to UpdateOne and ReplaceOne Sep 10, 2024
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.

1 participant