getActiveTransaction

函数: getActiveTransaction()

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

定义于: packages/db/src/transactions.ts:93

获取当前活动的内存事务(如果存在)。由集合操作内部使用,以加入现有事务。

Returns (返回)

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

活动的事务,如果没有活动事务则为 undefined。

示例

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)
}
我们的合作伙伴
Code Rabbit
Electric
Prisma
订阅 Bytes

您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。

Bytes

无垃圾邮件。您可以随时取消订阅。

订阅 Bytes

您的每周 JavaScript 资讯。每周一免费发送给超过 10 万开发者。

Bytes

无垃圾邮件。您可以随时取消订阅。