Querying DynamoDB by date

前端 未结 7 1356
予麋鹿
予麋鹿 2020-11-28 03:07

I\'m coming from a relational database background and trying to work with amazon\'s DynamoDB

I have a table with a hash key \"DataID\" and a range \"CreatedAt\" and

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 03:28

    Approach I followed to solve this problem is by created a Global Secondary Index as below. Not sure if this is the best approach but hopefully if it is useful to someone.

    Hash Key                 | Range Key
    ------------------------------------
    Date value of CreatedAt  | CreatedAt
    

    Limitation imposed on the HTTP API user to specify the number of days to retrieve data, defaulted to 24 hr.

    This way, I can always specify the HashKey as Current date's day and RangeKey can use > and < operators while retrieving. This way the data is also spread across multiple shards.

提交回复
热议问题