最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Query dynamoDB with key condition 'GE' on a hash key - Stack Overflow

matteradmin6PV0评论

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

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

Share Improve this question asked Mar 27, 2014 at 18:47 sonicfire3000sonicfire3000 371 gold badge2 silver badges5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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 parison 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 acplish 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.

Post a comment

comment list (0)

  1. No comments so far