view raw
Abdul Manaf Abdul Manaf - 6 months ago 87
Node.js Question

dynamo db error on update expression using node.js

i need to update a list on my aws-dynamo database. i have created a table with partition key : email. then iam insert some email id to the table successfully. Now my table like this


Then, i tried to update the table with new key "details" and its value is a list. this is my code

var AWS = require("aws-sdk");

var params =
TableName: "manaftable1",
Key: { email: "" },
UpdateExpression: "set #details = list_append (#details, :detailsinput)",
ExpressionAttributeNames: {
"#details": "details"
ExpressionAttributeValues: {
":detailsinput":{ "id": "1","mob": "978956" }

var docClient = new AWS.DynamoDB.DocumentClient();

docClient.update(params, function (err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
console.log(JSON.stringify(data, null, 2));

But i got error like this

"message": "Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: M",
"code": "ValidationException",
"time": "2016-10-26T11:04:60.756",
"statusCode": 400,
"retryable": false,
"retryDelay": 0

i need response like this after updation

column1 : email

column2 : details |
[{"id":"1","mob":"978956"},{"id":"2","mob":"767886"}] |

what is the issue related with my code?


When the details attribute is NOT present in the item, the update expression should have just SET without the list_append.

UpdateExpression : "SET #details = :details"

When the details attribute is present in the item and the new update needs to add additional elements in the list, then list_append can be used to add the new element to the list.

UpdateExpression : "set #details = list_append (#details, :details)"