Search code examples
amazon-web-servicespaginationamazon-dynamodbboto3

I have a boto3 lambda function which uses table.scan to scan the dynamoDB. I want to send limited data to frontend to show 10 entries, cant use query


I want someone to help me with how to implement pagination in boto3 without query, NextToken. I want the dynamoDB data to be sent to the frontend but 10 entries at a time and every time send the next 10 entries to the frontend. First I thought I could use the query but the primary key would filter most of the data and I want all the results, just 10 entries at a time. Also on the frontend, it has to be like page1(10 entries), page2(next 10 ) , like that .


Solution

  • There's no direct approach from what I'm getting your question.

    Above mentioned approach by Mark B is good but not for your case you won't be able to move to any page other than next or go to previous page directly with this approach.

    You can implement a not so cost efficient approach by adding a field to db of page number and using a lambda function to maintain pagination in db