Updating a Set in Dynamo db using Node Js

一曲冷凌霜 提交于 2019-12-06 09:24:00

It looks like this:

'ExpressionAttributeValues' : {
    ':attrValue' : {
        "NS" : sm
    }
}

Should be this:

'ExpressionAttributeValues' : {
    ':attrValue' : {
        "S" : sm
    }
}

Or you need to cast this value sm[0] = "56465"; to a Number Number("56465") and change the :attrValue data type "S" to "N". Depends on how you have your table configured.

It's possible too that you should assign :attrValue to be "S" : sm[0] because right now you are passing an "S" a whole array.

I got a proper solution

var item = {"endTime": "7pm", "imageName": "7abcd", "startTime": "7pm"};

dynamo.updateItem({
    TableName:'TableName',
    Key:{"BucketName":"abcdefg" }, 
    UpdateExpression : "SET #attrName = list_append(#attrName, :attrValue)",
    ExpressionAttributeNames : {
        "#attrName" : "ImageLists"
    },
    ExpressionAttributeValues : {
        ':attrValue' : [item]
    }
},function(err, data) {
    if (err)
        console.log(err);
    else
        console.log(data)
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!