node-mongodb-native icon indicating copy to clipboard operation
node-mongodb-native copied to clipboard

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

Open aditi-khare-mongoDB opened this issue 1 year ago • 0 comments

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 avatar Sep 10 '24 19:09 aditi-khare-mongoDB