I am using the api "updateItem" in AWS dynamodb for update the items. The main feature will be add the new item or delete one existed item. However, none of them works in the following code, the error message for the ADD is " "ValidationException: Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: S. Here is the my code:
const data = "newData";
async function updatedb(data) {
return new Promise((resolve, reject) =>{
var params = {
Key: {
"lists": {
S: data
}
},
TableName: "old_lists_DB",
UpdateExpression: "SET #L = list_append(:v,#L) ",
ExpressionAttributeNames: {
"#L": "lists",
},
ExpressionAttributeValues: {
":v": {
S: data
}
}
};
dynamodb.updateItem(params, function(err,data) {
if(err){
reject(err);
}else{
resolve(data);
}
});
});
}
The schema of the old_lists_DB is very simple, only has one attribute : lists, and the value is a set of string. For example:
{
{"lists" : "a"},
{"lists" : "b"},
{"lists" : "c"},
}
return dynamodb.updateItem(params).promise(). - jarmod