跳到主要内容

WorkingTreeRestoreResult

type WorkingTreeRestoreResult =
| {
ok: true;
restoredCount: number;
sessionId: string | null;
workingTreeRevision: number;
}
| {
conflict: CommitConflict;
ok: false;
reason: "conflict";
}
| {
ok: false;
reason: "dirty_working_tree";
}
| {
incompatible: RestoreIncompatibility;
ok: false;
reason: "incompatible_schema";
}
| {
ok: false;
reason: "unreachable_target";
};

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/restore-command.ts:102

一次 restore() 的结果。

Union Members​

Type Literal​

{
ok: true;
restoredCount: number;
sessionId: string | null;
workingTreeRevision: number;
}

ok​

readonly ok: true;

本次恢复已落库;restoredCount: 0 时是一次什么都没写的 no-op

restoredCount​

readonly restoredCount: number;

写进工作树的条目数

sessionId​

readonly sessionId: string | null;

本次建立的恢复会话 id;no-op 时为 null(没建会话)

workingTreeRevision​

readonly workingTreeRevision: number;

本次调用之后的工作树 revision;no-op 时等于调用前的值


Type Literal​

{
conflict: CommitConflict;
ok: false;
reason: "conflict";
}

conflict​

readonly conflict: CommitConflict;

诊断值;不入库,也没有「清除冲突」的 API

ok​

readonly ok: false;

三个捕获位对不上,或 CAS 未命中;一个字节都没落地

reason​

readonly reason: "conflict";

判别位


Type Literal​

{
ok: false;
reason: "dirty_working_tree";
}

ok​

readonly ok: false;

工作树不干净,本次恢复被拒;持久状态零变化

reason​

readonly reason: "dirty_working_tree";

判别位


Type Literal​

{
incompatible: RestoreIncompatibility;
ok: false;
reason: "incompatible_schema";
}

incompatible​

readonly incompatible: RestoreIncompatibility;

首个不兼容节点的稳定描述,不含 patch 内容(FR-050、FR-043)

ok​

readonly ok: false;

重放路径上有本客户端认不出的实体;持久状态零变化

reason​

readonly reason: "incompatible_schema";

判别位


Type Literal​

{
ok: false;
reason: "unreachable_target";
}

ok​

readonly ok: false;

目标 commit 从当前 HEAD 够不到;持久状态零变化

reason​

readonly reason: "unreachable_target";

判别位

Remarks​

成功出口恰好四个字段,一个都不多:调用方想看看「恢复了什么」时,最顺手的实现是把 patch 抄一份挂上来,而那份 patch 里可能躺着加密列的密文(FR-043)。要看内容走 diff(),恢复出来的 条目在那里与手写变更同形。

restoredCount: 0 加 sessionId: null 就是 no-op 的全部含义,不另立一个 noop 布尔位——多一位 就多一个会与 restoredCount 对不上的地方(FR-042)。