Prisma ORM · Prisma Client queries

Group rows

Group by a field and count each group.

const byRole = await prisma.user.groupBy({ by: ["role"], _count: { _all: true } });

Official Prisma ORM documentation

More prisma client queries commands

All prisma client queries commands · Prisma ORM cheatsheet

Was this page helpful?