Usman Ismail
Usman Ismail

Reputation: 18689

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.

Upvotes: 6

Views: 4620

Answers (1)

Steffen Opel
Steffen Opel

Reputation: 64771

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]

Upvotes: 7

Related Questions