Knex.js多个orderBy()列 [英] Knex.js multiple orderBy() columns

查看:109
本文介绍了Knex.js多个orderBy()列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以做多个orderBy()列?

Is it possible to do multiple orderBy() columns?

knex
  .select()
  .table('products')
  .orderBy('id', 'asc')

可链接的orderBy()仅需要一个列键和一个排序值,但是如何按多列排序?

The orderBy() chainable only takes a single column key and a sort value, but how can I order by multiple columns?

推荐答案

您可以

You can call .orderBy multiple times to order by multiple columns:

knex
  .select()
  .table('products')
  .orderBy('name', 'desc')
  .orderBy('id', 'asc')

这篇关于Knex.js多个orderBy()列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆