pagination
Hi all. I'm trying to wrap my head around pagination with
convex.dev
. Does the getPage
helper function also support filtering the data been paginated? If not, how can I filter the data and then apply pagination? The getPage
examples in the documentation only show pagination on the whole table, not a subset of its data (I hope I'm making sense).6 Replies
hi! have you considered using
db.query(...).withIndex(...).paginate(...)
https://docs.convex.dev/database/paginationPaginated Queries | Convex Developer Hub
Load paginated queries.
getPage
is only useful if you want to do very advanced patternsHi @lee Yes, I've been using
.paginate
most of the time. Now I have a use case where I would like to implement something like the image I paste where user can "jump" to specific pages. I'm trying to see how getPage
can help me achieve this feature since the docs say it gives more flexibilityok cool.
getPage
works for that but mainly if your pages are defined by specific index range boundaries. if you want pages based on the number of documents, you'll need to skip over documents by index, which could be accomplished by something like https://www.convex.dev/components/aggregateAggregate
Keep track of sums and counts in a denormalized and scalable way.
specifically this section https://www.convex.dev/components/aggregate#offset-based-pagination
Aggregate
Keep track of sums and counts in a denormalized and scalable way.
Thanks @lee I'll go through the above documentation