跳到主要内容

readCurrentBranchId()

function readCurrentBranchId(tx): Promise<string>;

Defined in: packages/rxdb-adapter-sqlite-core/src/version/with_triggers_disabled.ts:36

读当前分支 id(activated 优先,否则 main),供重建触发器使用。

Parameters​

ParameterTypeDescription
txSqlExecutor当前事务的执行器

Returns​

Promise<string>

当前活跃分支 id

Throws​

RxDBAdapterSqliteError 元数据缺列或读不到任何分支时抛出,让事务回滚

Remarks​

不能走 versionManager.getCurrentBranch(): C2 下仓库读写经真实适配器会重新入队(并发度 1)。pullRepository 在外层 adapter.transaction 里调 executor.mergeChanges(..., disableTriggers=true) 时, 队列槽位仍被外层事务占用;再入队读分支会排在自己身后永久挂起。 这里经当前事务 executor 直发 SQL。

判定本身在 read_current_branch_id.ts,本函数只把 execute 的结果形状 (包在 results[0] 里)摊成那一份要的扁平形状:两份各写一遍的时候,?? 'id' 兜底的 那次删除只落在了其中一份上。