Reputation: 2025
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"
};
Upvotes: 3
Views: 7448
Reputation: 77
Use the String Set attribute to update the list.
ExpressionAttributeValues: {
":html": {
SS: aws.StringSlice(your_html_array)
}
Upvotes: 0
Reputation: 5205
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.
Upvotes: 5