Add / remove item to array in Amazon DynamoDB

I am considering the most efficient atomic way to add an element to an array inside a DynamoDB object. Right now, when I see that adding something to the array atomically, the version approach is used: fetching the field to update, adding / removing a value, and performing a conditional update with the version field in the row. But it does not look super efficient for me. Is there a better way to do this?

+6
source share
1 answer

The UpdateItem operation has Add and Delete actions. If they are used in sets, actions will add / remove the specified values ​​from the set. If used for a number, the Add action will atomically increase or decrease the number.

It is important to remember that DynamoDB actually supports sets, not arrays. Because of this, adding or removing values ​​is inherently atomic.

+11
source

Source: https://habr.com/ru/post/909893/


All Articles