function getActiveTransaction():
| undefined
| Transaction<Record<string, unknown>>
function getActiveTransaction():
| undefined
| Transaction<Record<string, unknown>>
定义于: packages/db/src/transactions.ts:93
获取当前活动的内存事务(如果存在)。由集合操作内部使用,以加入现有事务。
| undefined | Transaction<Record<string, unknown>>
活动的事务,如果没有活动事务则为 undefined。
// 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)
}
您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。