Amazon DynamoDB
UpdateMultiple
3 samples, from the least code that works to complete workflows.
What an UpdateMultiple does
| Rule | On DynamoDB |
|---|---|
| Many entities | UpdateMultiple is all or nothing, in one TransactWriteItems (up to 100) |
| By a filter | UpdateMultipleAsync(values, filter) and DeleteMultipleAsync(table, filter): the filter gives a partition key of the table or an index (ARX8001 otherwise); one query, then one transaction of at most 100 writes, each conditioned on the filter still matching (Basic2). From 0.1.0-preview.5 |
The samples
Basics
The least code that works.
1Update many records in one callProgressiveMany items in one call, all or nothing, in two scenarios: a different price for each product, and a list with one SKU no item has, where none of them changes.
Every item a filter matches, changed or deleted in one call. DynamoDB reads by partition, so the filter gives one (a customer's orders); ARX finds the items with one query, then writes each by its key in one transaction, conditioned on the filter still matching it.
Advanced cases
Dependency injection, transactions, batch scopes and setting the service up.
1A security check around updatesAdvancedA security check around a batch of updates (SecurityGuard), in three scenarios: a batch of changes passes, an attack in one item refuses the whole batch, and repeated attacks block the user.