I’m using NodeJS, Express and Dynamoose modeling tool to work with AWS DynamoDB.
Currently, I want to handle data query with pagination of 1.000 users: UserID, UserName, CreatedAt
Basically, I want to call an Express API to fetch all users with 10 users per page, for example:
POST: /users/all
Request body:
{
"currentPage": 2,
"itemsPerPage": 10
}
And in my code it should query all user records with Partition Key: “User”, and Sort Key: “User Data”, sort by CreatedAt descending.
My expectation that the API response returns like this:
{
"data": [],
"pageInfo": {
"currentPage": 2,
"totalPages": 100,
"itemsPerPage": 10,
"totalItems": 1000
}
}
I understand that AWS DynamoDB returns LastEvaluatedKey but I want the page numbers instead, can you please help?