Subscribes to a collection query built using query objects ({@link order | order}, {@link where | where}, {@link limit | limit}).
import { query, limit, order, startAfter, collection } from 'typesaurus'
type Contact = { name: string; year: number }
const contacts = collection<Contact>('contacts')
onQuery(contacts, [
order('year', 'asc', [startAfter(2000)]),
limit(2)
], bornAfter2000 => {
console.log(bornAfter2000)
//=> 420
console.log(bornAfter2000[0].ref.id)
//=> '00sHm46UWKObv2W7XK9e'
console.log(bornAfter2000[0].data)
//=> { name: 'Sasha' }
})
The collection or collection group to query
The query objects
The function which is called with the query result when the initial fetch is resolved or the query result updates.
The function is called with error when request fails.
Function that unsubscribes the listener from the updates
Generated using TypeDoc
The query type.