orderBy
The order field can receive multiple inputs and all of them will result in the same query:
- a single string
- an array of strings
- an object of a {string: another string} (field + orientation)
- an object of a {string: instance of the Order Enum} (field + orientation)
Order by a single field with the default orientation¶
const qb = new D1QB(env.DB)
const fetched = await qb
.fetchAll({
tableName: 'employees',
orderBy: 'id',
})
.execute()
Order by a single field with the Order Enum orientation¶
import { OrderTypes } from 'workers-qb'
const qb = new D1QB(env.DB)
const fetched = await qb
.fetchAll({
tableName: 'employees',
orderBy: { id: OrderTypes.DESC },
})
.execute()
Order by a single field with a string orientation¶
const qb = new D1QB(env.DB)
const fetched = await qb
.fetchAll({
tableName: 'employees',
orderBy: { id: 'DESC' },
})
.execute()