【问题标题】:Prisma 2: Unknown arg `where` in select.count.where for type undefinedPrisma 2:未知 arg `where` 在 select.count.where 类型未定义
【发布时间】:2020-11-02 06:48:24
【问题描述】:

我无法将 where 子句应用于模型上的简单 count() 查询。如果我删除 where 子句,它就可以正常工作并返回该表中的行数。

好: 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 prisma2


    【解决方案1】:

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

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

    【讨论】:

    • Bingo - 版本略有不同。谢谢!
    猜你喜欢
    • 2022-07-06
    • 1970-01-01
    • 2021-12-03
    • 2022-08-19
    • 2019-11-30
    • 2022-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多