feat(NODE-6290): add sort option to UpdateOne and ReplaceOne
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:lintscript - [ ] 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
- Example:
- [ ] Changes are covered by tests
- [ ] New TODOs have a related JIRA ticket