2015-09-13 81 views
0

我認爲這應該工作使用表達式語法dynamodb更新項目,但它並不:如何與散列和範圍表

$response = $client->updateItem(array(
    'TableName' => 'ximoIsThisYou', 
    'KeyConditionExpression' => 'rep_num = :v_hash and record_created = :v_range', 
    'ExpressionAttributeValues' => array (
    ':v_hash' => array('S' => $rep_num), 
    ':v_range' => array('N' => $record_created), 
    ':val1' => array('S' => '447747') 
), 
    'UpdateExpression' => 'set vimeo_id = :val1', 
    'ReturnValues' => 'ALL_NEW' 
)); 

我得到這個錯誤:

Uncaught Aws\DynamoDb\Exception\ValidationException: 
AWS Error Code: ValidationException, Status Code: 400, 
AWS Request ID: UOPKLQER1MI3ANF48PU92IAC3VVV4KQNSO5AEMVJF66Q9ASUAAJG, 
AWS Error Type: client, 
AWS Error Message: 1 validation error detected: Value null at 'key' failed to satisfy constraint: Member must not be null, 
User-Agent: aws-sdk-php2/2.8.2 Guzzle/3.9.3 curl/7.35.0 PHP/5.5.9-1ubuntu4.11 

然而,這工作:

$response = $client->query(array(
    'TableName' => 'ximoIsThisYou', 
    'KeyConditionExpression' => 'rep_num = :v_hash and record_created = :v_range', 
    'ExpressionAttributeValues' => array (
    ':v_hash' => array('S' => $rep_num), 
    ':v_range' => array('N' => $record_created) 
), 
)); 

回答

1

KeyConditionExpression是用於​​的參數。

The condition that specifies the key value(s) for items to be retrieved by the Query action.

您正在試圖調用UpdateItem,這需要Key。您正在收到驗證錯誤,因爲您尚未設置所需的請求參數Key