Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

getactivetransaction.md

36 lines897 Bytes

Function: getActiveTransaction()

function getActiveTransaction(): 
  | undefined
| Transaction<Record<string, unknown>>

Defined in: packages/db/src/transactions.ts:93

Gets the currently active ambient transaction, if any Used internally by collection operations to join existing transactions

Returns

| undefined | Transaction<Record<string, unknown>>

The active transaction or undefined if none is active

Example

// Check if operations will join an ambient transaction
const ambientTx = getActiveTransaction()
if (ambientTx) {
  console.log('Operations will join transaction:', ambientTx.id)
}