noob saibot
noob saibot2mo ago

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
lee
lee2mo ago
hi! have you considered using db.query(...).withIndex(...).paginate(...) https://docs.convex.dev/database/pagination
lee
lee2mo ago
getPage is only useful if you want to do very advanced patterns
noob saibot
noob saibotOP2mo ago
Hi @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 flexibility
No description
lee
lee2mo ago
ok 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/aggregate
Aggregate
Keep track of sums and counts in a denormalized and scalable way.
lee
lee2mo ago
Aggregate
Keep track of sums and counts in a denormalized and scalable way.
noob saibot
noob saibotOP2mo ago
Thanks @lee I'll go through the above documentation

Did you find this page helpful?