I am trying to append a message to an empty list in AWS DynamoDB.
Here is the error that I get when I run the function
Invalid UpdateExpression: Incorrect number of operands for operator or function; operator or function: list_append, number of operands: 1
Data structure in DynamodB
Below is the code:
var caseId = "1734009";
var chatMessage = { "2018-04-20T15:02:48Z":
{
"userId": "wQnUJrklzwWBDOsx83XVETSS7us2",
"message": "How are you"
}
}
var params = {
TableName : 'CHATS',
Key: {
"CASE_ID" : caseId
},
UpdateExpression : "SET CHAT_MESSAGES = list_append(:i)",
ExpressionAttributeValues : {
':i': [chatMessage],
},
ReturnValues:'UPDATED_NEW' // OTHER OPTIONS: NONE | ALL_OLD | UPDATED_OLD | ALL_NEW | UPDATED_NEW
};
documentClient.update(params, function(err, data) {
if(err) {
var message = "Chat message could not be saved, error:" + JSON.stringify(err, null, 2);
res.json({"status": "failure", "statusCode" : 400, "message": message});
} else {
next();
}
});
