getActiveTransaction

Function: getActiveTransaction()

ts
function getActiveTransaction(): 
  | undefined
| Transaction<Record<string, unknown>>
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

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)
}
Our Partners
Electric
Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.