[英]I want to sort string column with Prisma not use $queryRaw
I use MySQL.我使用 MySQL。
A column called AGE
contains numbers in the form of a string.名为
AGE
的列包含字符串形式的数字。
If I use prisma to sort, it's not 1-2-...-9如果我用 prisma 排序,就不是 1-2-...-9
1-11-2-333-...-88-9 Sort like this. 1-11-2-333-...-88-9 像这样排序。
I would like to know if there is any way to sort other than using $queryRaw.我想知道除了使用 $queryRaw 之外是否还有其他排序方式。
Your model will look something like:您的 model 将类似于:
model Person {
id Int @id
name String
age Int
}
The type definition Prisma generates for the orderBy
field is: Prisma 为
orderBy
字段生成的类型定义是:
export type PersonOrderByWithRelationInput = {
id?: SortOrder
name?: SortOrder
age?: SortOrder
}
…and SortOrder
is defined as: ...并且
SortOrder
定义为:
export const SortOrder: {
asc: 'asc',
desc: 'desc'
};
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
Unfortunately this means it is not possible to get orderBy
to do what you want here.不幸的是,这意味着不可能让
orderBy
在这里做你想做的事。
Your options here are:您的选择是:
queryRaw
,queryRaw
,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.