문제

I'm trying to run a query on a dynamoDB table with the key condition as such

KeyConditions: {
  userID: {
    ComparisonOperator: 'GE',
    AttributeValueList: [{N: '0'}]
  }
}

When I run this query with the ComparisonOperator as 'EQ' no problems occur. However when it's 'GE' I get an error stating that the query key condition is not supported.

Note that userID is a hash key

도움이 되었습니까?

해결책

From the Dynamo DB Query Documentation:

A Query operation directly accesses items from a table using the table primary key, or from an index using the index key. You must provide a specific hash key value. You can narrow the scope of the query by using comparison operators on the range key value, or on the index key. You can use the ScanIndexForward parameter to get results in forward or reverse order, by range key or by index key.

You must provide a hash key to query Dynamo DB. You could accomplish what you're trying to do with a Scan operation or with multiple Query operations, but there's no way to specify a condition other than equals for a hash key in DynamoDB.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top