Help! I'm building small wiki app with Prisma and being stuck at paginate function.

It's mind boggling that Prisma doesn't have something so common that is count total record for all page in paging. I search on on their GitHub and found out that they have this issue opened for 1 year, and in the mean time user have to query to database 2 times, 1 for count all and 1 for paginated data. This makes me wonder that which one is better, "count 300 records then get 20 records for 1 page" or "get all 300 records with no paging."? Is there any better way to solve this? Should I wait for this issue https://github.com/prisma/prisma/issues/7550 to be solved?
GitHub
Add findManyAndCount to return count of queried items · Issue #75...
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...
13 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
senbonzakura123486
let me see @Mihai Andrei as i check none in the doc show how should i do to count total record before paginate
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
senbonzakura123486
@PondWader as I check it didn't count all, it just count the number of record after paginated, which is totally useless
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
senbonzakura123486
then it's no better then .count
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
senbonzakura123486
what i want to achieve is get the result and count in 1 query, which can be done with mongoose
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
senbonzakura123486
@PondWader i'm using prisma mongodb here, this is not db's fault
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
senbonzakura123486
what i still wonder now is .count all faster than .findMany to get all tho, which if they are on par then i think i would do .findMany
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server