clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Other
490 stars 110 forks source link

paginated requests #132

Closed cdelgadob closed 6 years ago

cdelgadob commented 6 years ago

I need to make an infinite scroll in my UI, and for that I plan to use cursors inqueries to dynamodb

I have been diving into the code and saw that there's a paginatedRequest method in utils.js, which I couldn't find in the documentation - see here

Would this method work for request where I can set a cursos and a number of records to retrieve or should I use the low-level dynamodb API to achieve this?

Thanks in advance

Carlos

cdhowie commented 6 years ago

You can use .query(...).limit(n) to limit the results to n objects. If there is possibly more data beyond the limited results, the returned data will include an ExclusiveStartKey attribute, which you can pass to the .startKey() query method to obtain the next page. See the query documentation.