how to return the number of pages when doing pagination?

If I'm taking 20 results for each page, how do you also return the total of pages in the same query? Repeating the query without pagination? 🧐
2 Replies
RaphaelEtim
RaphaelEtim2d ago
Hi @K1|ller 👋 It is currently not possible to return boththe paginated results and the total count in a single query. We do have some related open issues to address this. https://github.com/prisma/prisma/issues/7550 https://github.com/prisma/prisma/issues/4990 As a workaround, you can try the solution shared in this issue comment
GitHub
Add findManyAndCount() to return count of queried items · Issue #...
In order to properly perform pagination, one has to know the total count of items. For example, in a list of 1000 users paged in groups of 100, you have to know that the last page is at skip 900. T...
GitHub
Retrieve pagination information · Issue #4990 · prisma/prisma
Problem Prisma client currently does not provide the ability to retrieve pagination information about a certain query, which prevents developers from accounting for a result set’s size in a variety...
K1|ller
K1|llerOP15h ago
thanks! i'll check the links

Did you find this page helpful?