Remove nested attributes from dynamoDB Items - nodejs

点点圈 提交于 2020-01-03 05:54:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!