0

我想在节点 orm 中使用 find 方法获取排序项目。我知道 find() 中有和 'order' 参数,它会给我从 'az' 中排序的项目。如果我想从“za”订单中获取项目我会怎么做这意味着如何在 node-orm 中使用“GROUP BY DESC”?

4

1 回答 1

0

有一种分组方法

UserModel.find({id: id_value}).groupBy({column1, column2}).order('-name')。

在 ORM 库中,您可以找到以下功能,它将为您提供更多指导。

export interface SelectQuery {
select(fields: string): SelectQuery;
calculateFoundRows: SelectQuery;
as(alias: string): SelectQuery;
fun(fun: string, column: string, alias: string): SelectQuery;
from(table: string, from_id: string, to_id: string): SelectQuery;
from(table: string, from_id: string, to_table: string, to_id: string): SelectQuery;
where(...args: any[]): SelectQuery;
whereExists(table: string, table_link: string, link: string, conditions: { [column: string]: any }): SelectQuery;
groupBy(...columns: string[]): SelectQuery;
offset(offset: number): SelectQuery;
limit(limit: number): SelectQuery;
order(column: string, direction: string): SelectQuery;
build(): string;
}
于 2017-11-13T06:31:34.743 回答