2016-10-22 18 views
0

我試圖在閱讀官方文檔(https://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.NodeJs.03.html#GettingStarted.NodeJs.03.05)後使用條件寫入來更新DynamoDB表。我收到錯誤消息,我認爲這是一個語法錯誤,但我不知道,這是我的代碼:有條件地將DynamoDB:Expected params.ExpressionAttributeValues [':p']寫爲結構

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(https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ExpressionPlaceholders.html#ExpressionAttributeNames),但我沒有得到信息到可持續發展是我的問題。

回答

1

the documentation,改變這種:

"ExpressionAttributeValues":{ 
     ":p":true 
    } 

要:

"ExpressionAttributeValues":{ 
     ":p": {"BOOL": true} 
    } 
+0

感謝,並白癡錯誤=) –