Apply ascending order on given field
The order query object
Creates order query object with given field, ordering method and pagination cursors.
import { order, query, limit, startAfter, collection } from 'typesaurus'
type Contact = { name: string; year: number }
const contacts = collection<Contact>('contacts')
query(contacts, [
order('year', 'asc', [startAfter(2000)]),
//=> {
//=> type: 'order',
//=> field: 'year',
//=> method: 'asc',
//=> cursors: [{ method: 'startAt', value: 2000 }]
//=> }
limit(2)
]).then(bornAfter2000 => {
console.log(bornAfter2000)
//=> 420
})
Apply ascending order on given field with given cursors
Cursors that define pagination rules (startAfter, startAt, endBefore and endAt)
The order query object
Creates order query object with given field, ordering method and pagination cursors.
import { order, query, limit, startAfter, collection } from 'typesaurus'
type Contact = { name: string; year: number }
const contacts = collection<Contact>('contacts')
query(contacts, [
order('year', 'asc', [startAfter(2000)]),
//=> {
//=> type: 'order',
//=> field: 'year',
//=> method: 'asc',
//=> cursors: [{ method: 'startAt', value: 2000 }]
//=> }
limit(2)
]).then(bornAfter2000 => {
console.log(bornAfter2000)
//=> 420
})
Apply the order to the field
Used ordering method ('desc' or 'asc')
Cursors that define pagination rules (startAfter, startAt, endBefore and endAt)
The order query object
Generated using TypeDoc
Creates order query object with given field, ordering method and pagination cursors.
import { order, query, limit, startAfter, collection } from 'typesaurus' type Contact = { name: string; year: number } const contacts = collection<Contact>('contacts') query(contacts, [ order('year', 'asc', [startAfter(2000)]), //=> { //=> type: 'order', //=> field: 'year', //=> method: 'asc', //=> cursors: [{ method: 'startAt', value: 2000 }] //=> } limit(2) ]).then(bornAfter2000 => { console.log(bornAfter2000) //=> 420 })