0

In DynamoDB is it possible to use a query to get an item collection but have the order sorted by another attribute which is not a sort key?

For example:

UserId - PartitionKey
Type - SortKey
Timestamp

Is it possible to query by user ID and get all the type and ordered by the timestamp?

If not, would adding a GSI or LSI help here?

niyruu
  • 5
  • 3
  • I think you need to use LSI as it is used to maintain an alternate sort key for a given partition key value. – Arpit Jain Apr 27 '23 at 12:09
  • Is it possible to order by two attribute at the same time? My understanding was if you add another sort key, you can only order by it in one query and not order by both attribute. – niyruu Apr 27 '23 at 12:12
  • Yes that's why I mentioned alternative sort key :) – Arpit Jain Apr 27 '23 at 12:15

0 Answers0