Reputation: 319
I have games table.
To keep it simple, I will add only two fields for the question.
gameId:
deadlineToPlay:
I want to query for all games with deadlineToPlay > than today.
How would I set up the index for this? I thought I could create an index with just deadlineToPlay, but if I understand correctly when querying on hashkey, it has to be exact value. Can't use >.
I would also not like to use a scan, due to costs.
Upvotes: 0
Views: 31
Reputation: 477
A way to workaround this would be to create or use an existing field which will have constant value (for example, field hasDeadline
with value true
).
Now you can create the table key like this: hasDeadline
as HASH key and deadlineToPlay
as SORT key (if the table is already created, you can define this key in a new GSI).
This way you will be able to query by hasDeadline = true
and deadlineToPlay > today
.
Upvotes: 1