File: getActiveTransaction.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
React
Version
Latest
Search...
+ K
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
Framework
React
Version
Latest
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
On this page
Copy Markdown
Function: getActiveTransaction()
================================
ts
function getActiveTransaction():
| Transaction<Record<string, unknown>>
| undefined;
function getActiveTransaction():
| Transaction<Record<string, unknown>>
| undefined;
Defined in: packages/db/src/transactions.ts:175
Gets the currently active ambient transaction, if any Used internally by collection operations to join existing transactions
| Transaction <Record<string, unknown>> | undefined
The active transaction or undefined if none is active
ts
// Check if operations will join an ambient transaction
const ambientTx = getActiveTransaction()
if (ambientTx) {
console.log('Operations will join transaction:', ambientTx.id)
}
// Check if operations will join an ambient transaction
const ambientTx = getActiveTransaction()
if (ambientTx) {
console.log('Operations will join transaction:', ambientTx.id)
}
