Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prisma 2: Unknown arg `where` in select.count.where for type undefined

Tags:

prisma

prisma2

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?

like image 373
Dave Novelli Avatar asked Oct 15 '25 16:10

Dave Novelli


1 Answers

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.

like image 168
Ryan Avatar answered Oct 19 '25 13:10

Ryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!