본문으로 건너뛰기

함수: getActiveTransaction()

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

정의 위치: packages/db/src/transactions.ts:300

현재 활성 상태인 주변 트랜잭션을 가져옵니다(있는 경우). 컬렉션 작업에서 기존 트랜잭션에 참여하기 위해 내부적으로 사용됩니다.

반환값

| Transaction&lt;Record&lt;string, unknown>> | undefined

활성 트랜잭션 또는 활성 트랜잭션이 없으면 undefined입니다

예제

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