我正在尝试在DynamoDB表上执行更新.
代码是(Node.js):
let params = {
TableName: Organizations.Table,
Key: {
'ID': event.ID
},
UpdateExpression: 'SET #OrgName = :org, #Description = :desc',
ExpressionAttributeNames: {
'#OrgName': 'OrgName',
'#Description': 'Description'
},
ExpressionAtributeValues: {
':org': event.OrgName,
':desc': event.Description
},
ReturnValues: 'UPDATED_NEW'
};
this.docClient.update(params, (err, data) => {
if (err) {
return cb(err);
}
return cb(null, data);
});
Run Code Online (Sandbox Code Playgroud)
事件对象具有所需的所有属性.
执行后我得到一个错误:
无效的UpdateExpression:未定义表达式中使用的表达式属性值; 属性值:: desc
我只是按照DynamoDB文档中的示例进行操作.当我改变设定值的顺序时,例如SET #Description = :desc, #OrgName = :org我得到的错误将是关于属性值:org.我也尝试明确指定表达式属性值,没有帮助.
我不知道有什么不对.
有人能帮我吗?
not*_*est 16
ExpressionAtributeValues('t'缺失)存在拼写错误,导致问题.
请尝试以下.它应该工作.
UpdateExpression : "SET #OrgName = :org, #Description = :desc",
ExpressionAttributeNames: {
'#OrgName' : 'OrgName',
'#Description' : 'Description'
},
ExpressionAttributeValues: {':org' : 'new org value',
':desc' : 'new desc value'
},
ReturnValues: 'UPDATED_NEW'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10503 次 |
| 最近记录: |