Mehrfachauftrag von Knex
knex('users').orderBy([{ column: 'email' }, { column: 'age', order: 'desc' }])
Restu Wahyu Saputra
knex('users').orderBy([{ column: 'email' }, { column: 'age', order: 'desc' }])
.select()
.from('table')
.orderBy(['a', 'asc'], ['b', 'desc'], ['c','desc'])
.select()
.from('table')
.orderBy('a')
.orderBy('b', 'desc')
.orderBy('c', 'desc')
.select()
.from('table')
.orderBy({
a: 'asc',
b: 'desc',
c: 'desc',
});
knex('users').orderBy(['email', { column: 'age', order: 'desc' }])
var sortArray = [
{'field': 'title', 'direction': 'asc'},
{'field': 'id', 'direction': 'desc'}
];
knex
.select()
.table('products')
.modify(function(queryBuilder) {
_.each(sortArray, function(sort) {
queryBuilder.orderBy(sort.field, sort.direction);
});
})
.select()
.from('table')
.orderBy('a', 'asc', 'b', 'desc', 'c', 'desc')
.select()
.from('table')
.orderBy(['a','b','c'], ['asc', 'desc', 'desc'])
orderBy([
{ column: 'a', direction: 'asc' },
{ column: 'b', direction: 'desc' },
{ column: 'c', direction: 'desc' },
])
knex('users').orderBy(['email', 'age', 'name'])