Reputation: 3520
I am new to DynamoDB, and had a question how I can find all of the live entries in my DynamoDb table. Each entry in my table has a start and end date. I am confused on how I can query for the entries that the current date falls between the start and end date. Any ideas how I can do this?
I understand that I can only have a primary and range key. Is it possible to query for other columns in the entry?
Each entry looks like this:
id: xxxxxx startDate: 123456 // Epoch time endDate: 334243 // Epoch time
Upvotes: 0
Views: 1315
Reputation: 7440
If you do not know the hashkey of your item(looks like 'id' in your case) then the only way to query DynamoDB is using a full table scan.
You can do a table scan using multiple conditions, but this is inefficient.
Upvotes: 1
Reputation: 416
First you'll need to establish current epoch time. Then you can look to see if current epoch falls between your start and end epoch times. Most SQL variants have a BETWEEN(now, start, end)
function. If not, then you'd look for now >= start AND now <= end
. And yes, you can return any column in your query.
Upvotes: -3