Open RobertCraigie opened 3 years ago
Prisma supports including the count of a relational field, so we should too.
const users = await prisma.user.findMany({ include: { _count: { select: { posts: true }, }, }, })
which returns an object like this
{ id: 1, email: 'alice@prisma.io', name: 'Alice', _count: { posts: 2 } }
Prisma also have support for filtering by the count of the relation, see https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#filter-the-relation-count
This feature is needed.
Problem
Prisma supports including the count of a relational field, so we should too.
which returns an object like this
Prisma also have support for filtering by the count of the relation, see https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#filter-the-relation-count