2015-09-13 44 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