Prisma: Type '{ where: { variable: "value"; }; }' is not assignable to type 'boolean'

Viewed 27

So I am using prisma and I am trying to get the count of votes on thread where the vote value is VoteStatus.down. I am following the docs here.

I am getting Type '{ where: { vote: "down"; }; }' is not assignable to type 'boolean'. when I do this:

await this.prisma.thread.findMany({
  select: {
    _count: {
      select: {
        votes: { where: { vote: VoteStatus.down } }
      }
    }
  }
});

Here are my models in schema.prisma (note: I have modified for simplicity of the question):

model Thread {
  id          Int      @id @default(autoincrement())
  votes       ThreadVote[]
}

model ThreadVote {
  id Int @id @default(autoincrement())
  thread   Thread     @relation(fields: [threadId], references: [id])
  threadId Int
  vote     VoteStatus
}

enum VoteStatus {
  up
  down
}

I'm wondering if there is a bug in prisma? It seems to line up with the docs perfectly. Note that I am on Prisma 4.3.1.

Edit: I am now thinking it is because I have to add the filter relation count:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["filteredRelationCount"]
}
0 Answers
Related