Knex.js multiple orderBy() columns

后端 未结 4 1161
天命终不由人
天命终不由人 2021-02-18 18:27

Is it possible to do multiple orderBy() columns?

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

The orderBy() chainable on

4条回答
  •  醉酒成梦
    2021-02-18 19:30

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

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

提交回复
热议问题