我有一个超级简单的DynamoDB表:
CurrencyExchange:
Type: AWS::DynamoDB::Table
Properties:
TableName: 'MyTable'
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: 'RDate'
AttributeType: 'S'
KeySchema:
- AttributeName: 'RDate'
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: DateIndex
KeySchema:
- AttributeName: 'RDate'
KeyType: HASH
Projection:
ProjectionType: ALL
我要做的就是找到最高的键值。我没有用作条件的查询值,因此我尝试了
$iteratorParameters = [
'TableName' => 'MyTable',
'Limit' => 1,
'IndexName' => 'DateIndex',
'ScanIndexForward' => true
];
$result = DynamoDbFacade::query($iteratorParameters);
但我知道
{
"__type":"com.amazon.coral.validate#ValidationException",
"message":"Either the KeyConditions or KeyConditionExpression parameter must be specified in the request."
}
我可以将KeyConditions
与这些运算符[IN, NULL, BETWEEN, LT, NOT_CONTAINS, EQ, GT, NOT_NULL, NE, LE, BEGINS_WITH, GE, CONTAINS]
之一配合使用
但如果我这样做
$iteratorParameters = [
'TableName' => 'MyTable',
'Limit' => 1,
'KeyConditions' => [
'RDate' => [
'ComparisonOperator' => 'NOT_NULL'
],
],
'IndexName' => 'DateIndex',
'ScanIndexForward' => true
];
$result = DynamoDbFacade::query($iteratorParameters);
我明白了
{
"__type":"com.amazon.coral.validate#ValidationException",
"message":"Attempted conditional constraint is not an indexable operation"
}
哪个是找到最大键值的正确方法?