Retrieves a document from a collection.
import { transaction, collection } from 'typesaurus'
type Counter = { count: number }
const counters = collection<Counter>('counters')
transaction(
({ get }) => get('420'),
//=> { __type__: 'doc', data: { count: 42 }, ... }
({ data: counter, set }) =>
set(counter.ref, { count: counter.data.count + 1 })
)
The reference to the document
Promise to the document or null if not found
The collection to get document from
The document id
Generated using TypeDoc
The transaction read API object. It contains get the function that allows reading documents from the database.