chrisTina
chrisTina

Reputation: 2368

DynamodbDB query without a range key

I have table defined with two column, column 1 is the hash key and column 2 is the range key. I want to get all items defined with the same hash key (so the range key doesn't matter).

I tried to use the new KeyPair().withHashKey(k). But it will throw exception saying that no RANGE key value present.

Is the only option I have is to do a scan for the table to achieve this?

Upvotes: 1

Views: 2343

Answers (1)

Jason Wadsworth
Jason Wadsworth

Reputation: 8887

I think the problem is that you are trying to use the GetItem call, which requires the complete key, and only returns one item. You need to use the Query call, and pass in a KeyExpression that only includes the partition key.

Upvotes: 5

Related Questions