Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve an item from a DynamoDB table that has a range key by only specifying the index key

I have a table with a primary key and range key set:

user_id
timestamp_joined

Using the boto api layer, is there a way I can retrieve the item just by specifying the user_id (without the range key)? Every time I perform a getItem() query without specifying the range key it fails. I can only get it to work by specifying the range key (timestamp_joined).

The error message when fetching just by user_id is below:

boto.exception.DynamoDBResponseError: DynamoDBResponseError: 400 Bad Request 
{'message': 'One or more parameter values were invalid: The provided 
key size does ot match with that of the schema', '__type':
'com.amazon.coral.validate#ValidationException'} 
like image 643
ensnare Avatar asked Oct 23 '22 11:10

ensnare


1 Answers

It sounds like you want to perform a query. You can query the table specifying only the user_id (the hash key) and the query will return all items that match that user_id regardless of the range value.

like image 148
garnaat Avatar answered Nov 03 '22 00:11

garnaat