4

I'm unable to apply a where clause to a simple count() query on a model. If I remove the where clause it works just fine and returns the number of rows in that table.

Good: let result = await prisma.articles.count()

Bad: let result = await prisma.articles.count({ where: { article_id: 1 } })

Error:

Unknown arg `where` in select.count.where for type undefined. Did you mean `select`? Available args:
type count {

}

It doesn't matter which column in the schema I use, same error. How do I troubleshoot this?

Dave Novelli
  • 2,086
  • 4
  • 32
  • 42

1 Answers1

5

The above syntax is correct. Could you confirm if your @prisma/cli and @prisma/client are on the same version. If so, could you run npx prisma generate and check again. I am currently on version 2.2.0 and it works for me.

Also as a last resort, reload your editor to check the updated types so that count can be detected.

Ryan
  • 5,229
  • 1
  • 20
  • 31