I have a DynamoDB messages table with id, content, createdAt (int), userID
fields.
I can obtain a user's messages using below resolver:
{
"version" : "2017-02-28",
"operation" : "Query",
"index" : "userid-createdat-index",
"query" : {
"expression": "userID = :userID",
"expressionValues" : {
":userID" : $util.dynamodb.toDynamoDBJson($context.arguments.userID)
}
}
}
My objective is to get user messages within the last 5 seconds using the createdAt field which is epoch time in milliseconds. I would like to avoid using Scan operation as my table will be large.
How do I do that? What kind of DynamoDB index do I need for it?