跳到主要内容

WorkingTreeCommands

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:73

三端入口对外暴露的十二个命令;签名与 WorkingTreeManager (以及 switchBranch 那一个 VersionManager)上的同名方法一致。

Remarks​

签名不做框架化改写:入参与返回值用的都是核心那一份类型(§1「共享同一份核心类型, 不各自重定义」)。commit() 在这里同样是「两个位置参数、CAS 落败走返回值」, 没有为了「好用」而省掉三个捕获位的重载——省掉它就等于让入口内部自己读一次 revision, 而内部读到的恒等于当前值,CAS 永远命中(FR-031 当场失效)。

Properties​

commit​

readonly commit: (message, options) => Promise<CommitResult>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:89

提交工作树里的全部未提交单元;没有「空成功」,零变更时原样抛 empty_commit

Parameters​

ParameterType
messagestring
optionsCommitOptions

Returns​

Promise<CommitResult>


commitChanges​

readonly commitChanges: (commitId) => Promise<CommitChangeSetPage>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:87

一个 commit 的全部变更单元;基线节点的零单元是 empty 相位

Parameters​

ParameterType
commitIdstring

Returns​

Promise<CommitChangeSetPage>


diff​

readonly diff: (options?) => Promise<WorkingTreeDiff>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:83

当前分支相对 HEAD 的未提交改动;零条目是 empty 相位

Parameters​

ParameterType
options?WorkingTreeDiffOptions

Returns​

Promise<WorkingTreeDiff>


discard​

readonly discard: (options) => Promise<WorkingTreeDiscardResult>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:91

把工作树整体退回 HEAD;discardedCount: 0 是 no-op,不是 empty

Parameters​

ParameterType
optionsWorkingTreeCredentials

Returns​

Promise<WorkingTreeDiscardResult>


enable​

readonly enable: () => Promise<CommitCapabilityInfo>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:77

启用提交能力;成功后顺带重读一次 status

Returns​

Promise<CommitCapabilityInfo>


enableIfEmpty​

readonly enableIfEmpty: () => Promise<WorkingTreeEnableIfEmptyResult>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:79

库为空时自动启用、有内容时跳过;三种结局后都顺带重读一次 status

Returns​

Promise<WorkingTreeEnableIfEmptyResult>


isEnabled​

readonly isEnabled: () => Promise<boolean>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:75

这个库启没启用提交能力;boolean 没有空形态,因此走命令状态

Returns​

Promise<boolean>


listCommits​

readonly listCommits: (options?) => Promise<CommitLogPage>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:85

当前分支的可达提交历史;空历史是 empty 相位

Parameters​

ParameterType
options?CommitLogOptions

Returns​

Promise<CommitLogPage>


restore​

readonly restore: (target, options) => Promise<WorkingTreeRestoreResult>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:93

把一个可达历史 commit 的内容写回工作树;四个被拒成因走返回值,不是异常

Parameters​

ParameterType
targetWorkingTreeRestoreTarget
optionsWorkingTreeCredentials

Returns​

Promise<WorkingTreeRestoreResult>


restoreSession​

readonly restoreSession: () => Promise<
| WorkingTreeRestoreSessionInfo
| null>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:98

当前分支那个未结束的恢复会话;没有就是 null,落在 empty 相位

Returns​

Promise< | WorkingTreeRestoreSessionInfo | null>


status​

readonly status: () => Promise<WorkingTreeStatus>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:81

当前分支的工作树摘要;干净工作树是 empty 相位

Returns​

Promise<WorkingTreeStatus>


switchBranch​

readonly switchBranch: (branchId, options?) => Promise<void>;

Defined in: packages/rxdb-plugin-working-tree/src/working-tree/working-tree-commands.ts:100

切到另一条分支;成功后顺带重读一次 status。被 requireClean 拒掉时抛 WorkingTreeDirtyError

Parameters​

ParameterType
branchIdstring
options?RxDBBranchSwitchPreconditions

Returns​

Promise<void>