Skip to content
26 changes: 25 additions & 1 deletion source/crud/crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,6 @@ class UpdateOptions {
*/
upsert: Optional<Boolean>;


/**
* Map of parameter names and values. Values must be constant or closed
* expressions that do not reference document fields. Parameters can then be
Expand All @@ -1070,6 +1069,18 @@ class UpdateOptions {
* and providing one will result in a server-side error.
*/
comment: Optional<any>;

/**
* Specify which document the operation updates if the query matches multiple
* documents. The first document matched by the sort order will be updated.
*
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* This option is only supported by servers >= 8.0. Older servers will report an error for using this option.
* The driver MUST raise an error if the caller explicitly provides a value with updateMany().
*
* @see https://www.mongodb.com/docs/manual/reference/command/update/
*/
sort: Optional<Document>;
}

class ReplaceOptions {
Expand Down Expand Up @@ -1380,6 +1391,17 @@ class UpdateOneModel implements WriteModel {
*/
hint: Optional<(String | Document)>;

/**
* Specify which document the operation updates if the query matches multiple
* documents. The first document matched by the sort order will be updated.
*
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
* This option is only supported by servers >= 8.0. Older servers will report an error for using this option.
*
* @see https://www.mongodb.com/docs/manual/reference/command/update/
*/
sort: Optional<Document>;

/**
* When true, creates a new document if no document matches the query.
*
Expand Down Expand Up @@ -2369,6 +2391,8 @@ aforementioned allowance in the SemVer spec.

## Changelog

- 2024-08-30: Add sort option to `updateOne`.

- 2024-02-20: Migrated from reStructuredText to Markdown.

- 2022-10-05: Remove spec front matter and reformat changelog.
Expand Down
256 changes: 256 additions & 0 deletions source/crud/tests/unified/bulkWrite-updateOne-sort.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading