Skip to main content

Class: DatabaseCommandExecutor

Defined in: electron/services/commands/DatabaseCommands.ts:226

Command executor that provides transaction-like semantics for command execution and rollback.

Remarks​

Retains only commands whose execution and immediate rollback both failed. Those commands can be retried in reverse order with rollbackAll.

Constructors​

Constructor​

new DatabaseCommandExecutor(): DatabaseCommandExecutor;

Returns​

DatabaseCommandExecutor

Properties​

executedCommands​

private readonly executedCommands: IDatabaseCommand<unknown>[] = [];

Defined in: electron/services/commands/DatabaseCommands.ts:228

Commands whose failed execution could not be rolled back immediately.

Methods​

execute()​

execute<TResult>(command: IDatabaseCommand<TResult>): Promise<TResult>;

Defined in: electron/services/commands/DatabaseCommands.ts:249

Executes a command with automatic rollback on failure.

Type Parameters​

TResult​

TResult

The result type returned by the command's execute method.

Parameters​

command​

IDatabaseCommand<TResult>

The IDatabaseCommand to execute.

Returns​

Promise<TResult>

Promise resolving to the command result.

Remarks​

Validates the command before execution. If execution fails, attempts to rollback the command. Successful commands are released immediately; failed commands are retained only when their immediate rollback fails.

Throws​

When command validation or execution fails.


rollbackAll()​

rollbackAll(): Promise<void>;

Defined in: electron/services/commands/DatabaseCommands.ts:308

Rolls back all executed commands in reverse order.

Returns​

Promise<void>

Promise resolving when all rollbacks are complete.

Remarks​

Retries rollback for commands whose immediate rollback failed, in reverse order. Individual rollback failures are collected but do not prevent other rollbacks from executing.

Throws​

AggregateError containing all rollback failures if any occurred.


clear()​

clear(): void;

Defined in: electron/services/commands/DatabaseCommands.ts:350

Clears the command history without performing rollback.

Returns​

void

Remarks​

Removes all references to previously executed commands. Does not attempt to revert any changes.


releaseCommand()​

private releaseCommand(command: IDatabaseCommand<unknown>): void;

Defined in: electron/services/commands/DatabaseCommands.ts:354

Parameters​

command​

IDatabaseCommand<unknown>

Returns​

void