Skip to main content

Function: withDatabaseOperation()

withDatabaseOperation<T>(operation: () => Promise<T>, operationName: string, eventEmitter?: TypedEventBus<UptimeEvents>, context?: UnknownRecord): Promise<T>

Defined in: electron/utils/operationalHooks.ts:476

Specialized wrapper for database operations with database-specific defaults.

Type Parameters

T

T

The return type of the database operation

Parameters

operation

() => Promise<T>

Database operation to execute with retry logic

operationName

string

Name of the database operation (will be prefixed with "database:")

eventEmitter?

TypedEventBus<UptimeEvents>

Optional event emitter for operation lifecycle events

context?

UnknownRecord

Optional context data to include in events

Returns

Promise<T>

Promise resolving to the operation result

Remarks

This function is a convenience wrapper around withOperationalHooks that applies database-optimized settings and adds a "database:" prefix to operation names for consistent event naming. While the underlying implementation is generic, this wrapper should only be used for actual database operations to maintain clear semantic boundaries and event categorization.