Sara
Sara10h ago

Feature Request: return the number the page is on in `.paginate()`

I've hit a use case where I need to know the total page number, Previous page number, and nextPage number, is there something I might be missing with results being returned from the query?
3 Replies
Convex Bot
Convex Bot10h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart10h ago
Haven’t tried this yet, but this is designed for your use case: https://discord.com/channels/1019350475847499849/1319668553171075184/1319668553171075184
lee
lee4h ago
Having "total page number" is actually pretty tricky. You can calculate it with something like https://www.convex.dev/components/sharded-counter or https://www.convex.dev/components/aggregate , but no matter how you calculate it will be fairly heavyweight
Convex
Sharded Counter
Scalable counter that can increment and decrement with high throughput.
Convex
Aggregate
Keep track of sums and counts in a denormalized and scalable way.