baseprime / dynamodb

DynamoDB data mapper for Node.js
Other
296 stars 88 forks source link

How to implement a pagination feature with scan? #69

Open bluerid opened 4 years ago

bluerid commented 4 years ago

I see this can be used to limit the display of results. Account.scan().limit(10).exec(printResults); But how do I tell the scan method to start from a particular record?

bluerid commented 4 years ago

@baseprime Can I get a response here?

roweldeguzman commented 4 years ago

@bluerid first you need a to scan your db with limit. like so:

Account.scan().limit(10).exec(callback)

if the scan returns LastEvaluatedKey object that means you have more data you DB, which you can then use to you next scan like so

Account.scan().limit(10).startKey(LastEvaluatedKey).exec(callback)