Getting Counts on Relations with Prisma Client

Опубликовано: 27 Июль 2026
на канале: Prisma
9,429
155

New at Prisma 2.20 is the ability to get the counts of related fields. This is useful for cases where you'd like to get the total number of records for a model through a relation.

For example, you may want to get Author records and the total number of Posts that each other has. This is easy at Prisma 2.20 with the selectRelationCount feature flag.

In this video, Ryan Chenkie demonstrates how to use the new relation count feature.

Check out the release notes for Prisma 2.20: https://github.com/prisma/prisma/rele...

------------------------
Next:
👉 Check Next video: Ordering By Relation Aggregates with Prisma Client -    • Ordering By Relation Aggregates with Prism...  
👉 Check Previous video: How To Choose a Database for your App -    • How To Choose a Database for your App  
-----------------------
📚 Resources:

✅ Subscribe to Prisma:    / @prismadata  
✅ Get help from the Prisma Community: https://slack.prisma.io/
✅ Learn more about Prisma:
◭ Website: https://www.prisma.io
◭ Docs: https://www.prisma.io/docs
◭ Quickstart: https://pris.ly/qstart

------------------------
💬 Connect with Prisma:
Twitter:   / prisma  
Discord: https://pris.ly/discord
LinkedIn:   / prisma-io