Skip to content

排序


order()

对查询结果进行排序,需要传两个参数

  • @param field 排序的字段
  • @param sort 排序规则,DESC倒序 ASC正序
  • (field: string, sort: SORT = 'DESC')

order()

Db('user').where('age', '>', 10).order('age').select()
Db('user').where('age', '>', 10).order('age').select()

最终的SQL语句为:

SELECT * FROM user WHERE age > 10 ORDER BY age DESC
SELECT * FROM user WHERE age > 10 ORDER BY age DESC

备案号:冀ICP备20015584号-2