Background
I have a dynamoDB table consisting of a Primary Partition Key clientID
("N") and a Primary Sort Key createdAt
("S") (as UTC ISO 8601 date) + some additional attributes.
Problem
I Want to query back, all items where createdAt BETWEEN
two dates and only for around 100 specific clientID
s at a time.
clientID
s I want to query, I cannot specify the sort keys, since I'm looking for anything, that happen within a timeframe. clientID
s at the same time (in looked at the ´IN´ operator, but that one does not do what I was hoping for). So in other words, how can I achieve this, without having to do a Query
for every single ClientID
in the timeframe?I ended up doing something else:
I added a new attribute on called index_date
which only holds the date part of created_at
(not time). Then I added a new secondary global index on this attribute, with created_at
as sort key. In this way, I can efficiently query back all items for one day (in a specific time frame if I want) at a time. Then process them afterwards.