Prisma ORM · Prisma Client queries

Count and aggregate

Count rows and compute statistics.

const total = await prisma.user.count({ where: { role: "USER" } });
const stats = await prisma.post.aggregate({ _count: true, _max: { createdAt: true } });

Official Prisma ORM documentation

More prisma client queries commands

All prisma client queries commands · Prisma ORM cheatsheet

Was this page helpful?