MongoDB
UpdateMultiple
2 samples, from the least code that works to complete workflows.
What an UpdateMultiple does
| Rule | On MongoDB |
|---|---|
| Many entities | UpdateMultiple is all or nothing, in a transaction; the same entity or the same match values twice is ARX1001 |
| By a filter | UpdateMultipleAsync(values, filter) and DeleteMultipleAsync(table, filter): one updateMany or deleteMany in a transaction, returning the count; no id in the values, an empty filter needs AllRows (Basic2). From 0.1.0-preview.5 |
The samples
Basics
The least code that works.
1Update many records in one callProgressiveMany documents in one call, all or nothing, in two scenarios: a different value for each document, and a list with one id no document has, where none of them changes.
Every document a filter matches, changed or deleted in one call: one updateMany (or deleteMany) with the filter as a query document, in a transaction, so a document refused half-way leaves every document as it was.