DEV Community

Building pagination with Prisma felt… unnecessarily complex

The author decided to build small projects to improve their full-stack development skills and chose Prisma as their ORM. When implementing pagination, they discovered that Prisma doesn't have a built-in method to return both data and total count in a single query. This requires running two separate queries, which can become a nightmare with complex conditions. The author found an open issue on Prisma's GitHub page, where users have been requesting a findManyAndCount feature since 2021. Workarounds include using transactions or Promise.all, but these approaches have data consistency issues. This experience reminded the author of the importance of checking tool limitations and evaluating tradeoffs when choosing tools. The author is looking for others to share their experiences with Prisma or other ORMs and how they handle similar issues.
favicon
dev.to
dev.to
Create attached notes ...