【发布时间】:2016-10-22 23:06:44
【问题描述】:
我正在尝试使用条件写入来更新我的 DynamoDB 表,在阅读了官方文档 (https://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.NodeJs.03.html#GettingStarted.NodeJs.03.05) 之后,我遇到了一个错误,我认为这是一个语法错误,但我不确定,这个是我的代码:
dynamodb.updateItem({
dynamodb.updateItem({
"TableName": "MyFavTable",
"Key":{
"MyFavKey": {
"S": "MyFavKey"
}
},
"UpdateExpression": "set MyLovelyBool=false",
"ConditionExpression": "MyLovelyBool == :p",
"ExpressionAttributeValues":{
":p":true
}
}, function(err, data) {
if (err) {
console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
}
});
这个运行“很好”,但我得到了这个错误:
Unable to update item. Error JSON: {
"message": "Expected params.ExpressionAttributeValues[':p'] to be a structure",
"code": "InvalidParameterType",
"time": "2016-10-22T14:48:42.961Z"
}
我检查了 json 是否有效,并且我在此处 (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ExpressionPlaceholders.html#ExpressionAttributeNames) 阅读了有关 ExpressionAttributeValues 的信息,但我没有获得解决问题的信息。
【问题讨论】:
标签: node.js amazon-web-services