Is it possible to ORDER results with Query or Scan API in DynamoDB?
I need to know if DynamoDB has something like [ORDER BY \'field\'] from SQL queries?
Tha
If you are using boto2 and you have the sort key on one of the columns in your table, you can sort what you retrieve in order or in reverse order by saying:
result = users.query_2(
account_type__eq='standard_user',
reverse=True)
If you are using boto3 and you have the sort key on the column that you want to sort the result by, you can sort the data you retrieve by saying:
result = users.query(
KeyConditionExpression=Key('account_type').eq('standard_user'),
ScanIndexForward=True)
Remember in boto3 if ScanIndexForward is true , DynamoDB returns the results in the order in which they are stored (by sort key value). This is the default behavior. If ScanIndexForward is false, DynamoDB reads the results in reverse order by sort key value, and then returns the results to the client.