Node.js 条件写入DynamoDB:应将params.expressionAttributeValue[';:p';]作为结构
我试图使用条件写入更新我的DynamoDB表,在阅读了官方文档()之后,我得到了一个错误,我认为这是一个语法错误,但我不确定,这是我的代码:Node.js 条件写入DynamoDB:应将params.expressionAttributeValue[';:p';]作为结构,node.js,amazon-web-services,Node.js,Amazon Web Services,我试图使用条件写入更新我的DynamoDB表,在阅读了官方文档()之后,我得到了一个错误,我认为这是一个语法错误,但我不确定,这是我的代码: dynamodb.updateItem({ dynamodb.updateItem({ "TableName": "MyFavTable", "Key":{ "MyFavKey": { "S": "MyFavKey" } }, "UpdateExpres
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是否有效,我在这里阅读了ExpressionAttributeValues(),但我没有获得解决问题的信息 Per,更改此选项:
"ExpressionAttributeValues":{
":p":true
}
致:
"ExpressionAttributeValues":{
":p": {"BOOL": true}
}