Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to append to multi-valued attributes in DynamoDB?

Is it possible to append to the list of values in a multi-valued attribute in an Amazon DynamoDB table? I am not quite able to figure it out using the put request. I would like to avoid the read, update, write logic if possible.

like image 387
Usman Ismail Avatar asked May 15 '12 15:05

Usman Ismail


People also ask

How do you update multiple items in a DynamoDB table?

The only way to update multiple items at the same time is use TransactionWrite operation provided by DynamoDB. But it comes with a limitation (25 at most for example). So keep in mind with that, you probable should do some limitation in your application as well.

How many attributes can a DynamoDB item have?

There is no limit to the number of attributes but the total item size is limited to 400kb. The maximum item size in DynamoDB is 400 KB, which includes both attribute name binary length (UTF-8 length) and attribute value lengths (again binary length).

What are the limitations of DynamoDB?

DynamoDB transactional API operations have the following constraints: A transaction cannot contain more than 100 unique items. A transaction cannot contain more than 4 MB of data. No two actions in a transaction can work against the same item in the same table.

Can a DynamoDB table have multiple hash keys?

Using normal DynamoDB operations you're allowed to query either only one hash key per request (using GetItem or Query operations) or all hash keys at once (using the Scan operation).


1 Answers

Assuming you are referring to String and Number Sets as outlined in Amazon DynamoDB Data Types, this is possible in Amazon DynamoDB by means of the UpdateItem operation indeed:

ADD— Only use the add action for numbers or if the target attribute is a set (including string sets). ADD does not work if the target attribute is a single string value. The specified value is added to a numeric value (incrementing or decrementing the existing numeric value) or added as an additional value in a string set. If a set of values is specified, the values are added to the existing set. For example if the original set is [1,2] and supplied value is 3, then after the add operation the set is [1,2,3], not [4,5]. [...] [emphasis mine]

like image 74
Steffen Opel Avatar answered Oct 03 '22 20:10

Steffen Opel