Abstract Class: DatabaseCommand<TResult>
Defined in: electron/services/commands/DatabaseCommands.ts:95
Abstract base class for database commands providing common functionality for event emission and dependency management.
Extended by
Type Parameters
TResult
TResult = void
The result type returned by the command's execute method.
Implements
IDatabaseCommand<TResult>
Constructors
Constructor
new DatabaseCommand<
TResult>(serviceFactory:DatabaseServiceFactory,eventEmitter:TypedEventBus<UptimeEvents>,cache:StandardizedCache<Site>):DatabaseCommand<TResult>
Defined in: electron/services/commands/DatabaseCommands.ts:156
Parameters
serviceFactory
eventEmitter
cache
Returns
DatabaseCommand<TResult>
Properties
cache
protectedreadonlycache:StandardizedCache<Site>
Defined in: electron/services/commands/DatabaseCommands.ts:99
Site cache for data synchronization during operations
eventEmitter
protectedreadonlyeventEmitter:TypedEventBus<UptimeEvents>
Defined in: electron/services/commands/DatabaseCommands.ts:102
Event bus for emitting command execution events
serviceFactory
protectedreadonlyserviceFactory:DatabaseServiceFactory
Defined in: electron/services/commands/DatabaseCommands.ts:105
Factory for accessing database services and repositories
Methods
emitFailureEvent()
protectedemitFailureEvent(eventType: keyofUptimeEvents,error:Error,data:Partial<UptimeEvents[keyofUptimeEvents]>):Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:120
Internal
Emits a failure event for the command operation.
Parameters
eventType
keyof UptimeEvents
The event type to emit.
error
The ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error that occurred.
data
Partial<UptimeEvents[keyof UptimeEvents]> = {}
Additional event data to include in the event payload.
Returns
Promise<void>
Remarks
Used internally to emit a typed event indicating command failure, including error details and additional event data.
emitSuccessEvent()
protectedemitSuccessEvent(eventType: keyofUptimeEvents,data:Partial<UptimeEvents[keyofUptimeEvents]>):Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:145
Internal
Emits a success event for the command operation.
Parameters
eventType
keyof UptimeEvents
The event type to emit.
data
Partial<UptimeEvents[keyof UptimeEvents]>
Additional event data to include in the event payload.
Returns
Promise<void>
Remarks
Used internally to emit a typed event indicating command success, including additional event data.
execute()
abstractexecute():Promise<TResult>
Defined in: electron/services/commands/DatabaseCommands.ts:166
Executes the command operation.
Returns
Promise<TResult>
Promise resolving to the operation result.
Remarks
Performs the main database operation encapsulated by the command.
Throws
When command execution fails.
Implementation of
getDescription()
abstractgetDescription():string
Defined in: electron/services/commands/DatabaseCommands.ts:168
Gets a description of the command for logging and debugging.
Returns
string
Human-readable command description.
Implementation of
IDatabaseCommand.getDescription
rollback()
abstractrollback():Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:170
Rolls back the command operation if possible.
Returns
Promise<void>
Promise resolving when rollback is complete.
Remarks
Attempts to revert the effects of the command. Not all commands require rollback.
Implementation of
validate()
abstractvalidate():Promise<{errors:string[];isValid:boolean; }>
Defined in: electron/services/commands/DatabaseCommands.ts:172
Validates the command before execution.
Returns
Promise<{ errors: string[]; isValid: boolean; }>
Promise resolving to validation result.
Remarks
Ensures the command is in a valid state before execution. Returns a validation result with errors if any.