Leo*_*ani 4 amazon-web-services node.js
在阅读官方文档(https://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.NodeJs.03.html#GettingStarted.NodeJs后,我正在尝试使用条件写入更新我的 DynamoDB 表。 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));
}
});
Run Code Online (Sandbox Code Playgroud)
我收到此错误后运行“正常”:
Unable to update item. Error JSON: {
"message": "Expected params.ExpressionAttributeValues[':p'] to be a structure",
"code": "InvalidParameterType",
"time": "2016-10-22T14:48:42.961Z"
}
Run Code Online (Sandbox Code Playgroud)
我检查 json 是否有效,我正在阅读有关 ExpressionAttributeValues 的内容(https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ExpressionPlaceholders.html#ExpressionAttributeNames),但我没有得到解决我的问题的信息.
根据文档,更改此:
"ExpressionAttributeValues":{
":p":true
}
Run Code Online (Sandbox Code Playgroud)
到:
"ExpressionAttributeValues":{
":p": {"BOOL": true}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2657 次 |
| 最近记录: |