Prisma 2:select.count.where 中未定义类型的未知 arg `where`

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

我无法将 where 子句应用于模型上的简单 count() 查询。如果我删除 where 子句它工作得很好并且 returns 中的行数 table.

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

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

错误:

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

}

无论我使用模式中的哪一列,同样的错误。我该如何解决这个问题?

以上语法正确。您能否确认您的 @prisma/cli@prisma/client 是否在同一版本上。如果是这样,您能否 运行 npx prisma generate 再检查一次。我目前使用的是 2.2.0 版本,它适合我。

作为最后的手段,请重新加载您的编辑器以检查更新的类型,以便可以检测到计数。