api.transactionDatabase()
Runs database-data operations inside a short-lived transaction.
Notes:
- Commits automatically when the callback resolves.
- Rolls back automatically when the callback throws.
- The default timeout is 15,000 ms.
- Use
{ flexTimeout: true }when the transaction intentionally needs the enclosing execution’s remaining timeout budget. - Long transactions reserve a database connection and may retain locks; keep waits and remote side effects outside the callback when possible.
- SERIALIZABLE is the default isolation level.
- Parallel tx.* operations are rejected; await each tx.* call sequentially.

