【发布时间】:2021-11-19 16:28:50
【问题描述】:
我很难找到如何通过 Prisma 中的count 字段订购。
查询如下所示:
const where = // ...
const limit = // ...
const skip = // ...
const data = await this.prisma.translation.findMany({
where,
take: limit,
skip: offset,
orderBy: {
count: 'asc'
// ^ here is the issue, because count seems to be reserved for aggregations
}
});
棱镜模型:
model Translation {
id String
count Int @default(0)
}
我在这里找到了文档https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#orderby,但它没有说明如何对 prisma 说计数并不意味着聚合而是列名。
我得到的错误:
Invalid `prisma.translation.findMany()` invocation:\n\n\n Failed to validate the query: `Assertion error: Attempted conversion of non-map ParsedInputValue (Single(String(\"asc\"))) into map failed..` at ``
附言。我在 GitHub 上发现了这个问题,它仍然是打开的 https://github.com/prisma/prisma/issues/7806,我也会在那里询问一些解决方法或什么的......
感谢您的帮助:-)
【问题讨论】:
标签: prisma