I have the following table:
ItemUUID (string) | Purchases (number) | Type (string)
--------------------------------------
book-a | 5 | book
book-b | 1 | book
book-c | 10 | book
Every time someone buys an item, I would like to increment the Purchases
. I then would like to query the table to get the most purchased items (ItemUUID
s sorted DESC by Purchases
)
I thought I could make ItemUUID
a primary key, and make a global secondary index on Type
with a sort key of Purchases
. Then query the GSI where Type = book
, leave sort key blank, and Sort Descending.
This is not working. Is my use case possible with DynamoDB?