The transaction body function type.
The function allows performing transactions. It accepts two functions.
The first receives transaction read API that allows
getting data from the database and pass it to the second function.
The second function gets transaction write API
with the data returned from the first function as data
property of the argument.
import { transaction, collection } from 'typesaurus'
type Counter = { count: number }
const counters = collection<Counter>('counters')
transaction(
({ get }) => get('420'),
({ data: counter, update }) =>
update(counter.ref, { count: counter.data.count + 1 })
)
the transaction read function that accepts transaction read API and returns data for write function
the transaction write function that accepts transaction write API with the data returned by the read function
Promise that is resolved when transaction is closed
Generated using TypeDoc
The transaction body function type.