I'm having hard times to find out how to order by count field in Prisma.
The query looks like this:
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
}
});
Prisma model:
model Translation {
id String
count Int @default(0)
}
I found the docs here https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#orderby but it does not say anything how to say to prisma that the count does not mean aggregation but a column name.
The error I'm getting:
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 ``
PS. I found this issue on GitHub that is still open https://github.com/prisma/prisma/issues/7806, gonna ask also there for some workaround or something...
Thanks for any help :-)