mongodb / specifications

Specifications related to MongoDB
http://specifications.readthedocs.io/en/latest
Other
389 stars 242 forks source link

DRIVERS-2822 Add sort option to `updateOne` #1644

Closed qingyang-hu closed 2 weeks ago

qingyang-hu commented 1 month ago

Summary

Add a sort option to updateOne() so if it matches more than one candidate document the first one matched by the sort order will be updated.

Background & Motivation

The new syntax allows a sort option to be supplied to an update command. The upstream server changes are at https://jira.mongodb.org/browse/SERVER-78140.

Some example commands can be found at: https://github.com/mongodb/mongo/commit/e443421240f5a111e19cf0870ff4f545deecea8c#diff-c9ff788fbdeb3594c45d85c449a[…]21f5ef32ede8f9c858e6e3072e0c8R27

The corresponding mongosh docs: https://www.mongodb.com/docs/upcoming/reference/method/db.collection.updateOne/ Though the command docs have not been updated yet.


Please complete the following before merging:

ShaneHarvey commented 1 month ago

Removing myself, I'll defer to Jeremy + the bulk write spec authors.

jmikola commented 1 month ago

@qingyang-hu: Please ping me for another review once the Bulk Write spec/tests are updated.

qingyang-hu commented 3 weeks ago

@jmikola, can you please take a look again? I've added the sort to the client-level bulk write.

qingyang-hu commented 3 weeks ago

@jmikola, can you please review the updates?