3

In my dynamoDB, I have a table that structure as like as given below:

 var params = {
      "TableName" : "pdfs",
      "Item" : {
          pdfid:  // Partition key
          html: [] // array attribute
       }
 };

I can insert new array data, just like as given code:

Insert array data

 var params = {
      "TableName" : "pdfs",
      "Item" : {
          pdfid: pdfid,
          html: [event.html]   // here "html" is an array, I just insert first array data
       }
 };

 dc.put(params, function(err, data) {
     ............................
 });

How can I update array in dynamoDB ?

  var params = {
      TableName: "pdfs",
      Key: {
         pdfid: event.pdfid
      },
      UpdateExpression: "SET html = :html",
      ExpressionAttributeValues: {
         ":html": ??????
      },
      ReturnValues: "ALL_NEW"
  };
1
  • 1
    If html is an array of Strings, then you should use StringSet data type, and then use ADD in the UpdateExpression Commented Jul 1, 2016 at 21:16

2 Answers 2

5

Use the following UpdateExpression to append values to a list: SET html = list_append(html, :html). The ExpressionAttributeValues would just be a mapping from :html to the string that you want to add.

Sign up to request clarification or add additional context in comments.

Comments

0

Use the String Set attribute to update the list.

ExpressionAttributeValues: {
         ":html": {
              SS: aws.StringSlice(your_html_array)    
      }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.