Hey! Have a question regarding using _count in a ....
# orm-help
b
Hey! Have a question regarding using _count in a .findMany-query I was under the impression I could count fields in a findMany query query:
Copy code
const result = await prisma.profile.findMany({
  distinct: ['schoolKey', 'sex'],
  where: {
    user: {
      emailVerified: {
        not: null,
      },
    },
  },

  select: {
    _count: {
      sex: true
    },
  },
});
I'm getting the error: Unknown field
_count
for select statement on model Profile.
r
@Bård 👋 We don’t support
count
with distinct at the moment. It would be great if you could add a 👍 to this request and also check the workaround specified in the form of a raw query 🙂
b
Cheers! Thanks for the swift reply - as always!
🙌 1