跳到主要内容

resolveSingleActiveBranch()

function resolveSingleActiveBranch(executor, host): Promise<RxDBBranch>;

Defined in: packages/rxdb/src/system/active-branch-guard.ts:271

只给首次启用迁移用:读出唯一的 active 分支,零 active 时恢复到 main。

Parameters​

ParameterTypeDescription
executorTransactionExecutor迁移那个事务的执行器
hostActiveBranchEntityHost需要新建 main 时用来 instantiate

Returns​

Promise<RxDBBranch>

唯一的 active 分支

Throws​

AmbiguousActiveBranchError 有多行 active 时;一行都不改, 由调用方回滚整条迁移

Remarks​

它比 assertSingleActiveBranch 多收一个参数,而那个参数正是「能不能修」的全部 区别:拿不到 instantiate 就建不出分支。这不是风格问题——多一个参数,就多一条 「顺手修一下」的路,而 FR-048 把恢复语义限定在首次迁移。