问题
I have a single item in dynamodb
{
"id": "123",
"201907240815": {
"userid1": {
"name": "Hello",
"email": "test@example.com"
},
"userid2": {
"name": "World",
"email": "world@example.com"
}
}
}
I need to remove the nested attribute. ex:201907240815.userid1
.
I had to try below code but it not worked
const param = {
TableName:'userinfo',
Key:{id:'123'},
UpdateExpression:'remove 201907240815.userid1',
ReturnValues: 'UPDATED_NEW'
}
try{
const response = await dynamoDB.update(param).promise();
return response;
}catch(e){
return e;
}
It could not be remove the attribute. I got this issue.
ValidationException: Invalid UpdateExpression: Syntax error; token: "201907240815", near: "remove 201907240815."
回答1:
I think that 'remove' should be capitalized: 'REMOVE'
来源:https://stackoverflow.com/questions/57187335/remove-nested-attributes-from-dynamodb-items-nodejs