Skip to main content

DatabaseClient

Abstract database client, to use as a blueprint for DBMS-specific implementations. Extends @perseid/server AbstractDatabaseClient class.


updateMatchingTask

Updates task that matches filters with payload.

public abstract updateMatchingTask(
filters: SearchFilters,
payload: Payload<DataModel['tasks']>,
): Promise<boolean>;

Parameters

  • filters: Filters to apply to match task.
  • payload: Updated task payload.

Returns

true if task was updated, false otherwise.

Usage

databaseClient.updateMatchingTask({
_id: new Id(),
_status: 'IN_PROGRESS'
}, { _status: 'COMPLETED' });

getRunningTasks

Fetches list of running tasks.

public abstract getRunningTasks(): Promise<DataModel['tasks'][]>;

Returns

Running tasks list.

Usage

await databaseClient.getRunningTasks(); // [...]

getCandidatePendingTasks

Fetches the list of pending tasks that are candidate for execution.

public abstract getCandidatePendingTasks(): Promise<DataModel['tasks'][]>;

Returns

Pending tasks list.

Usage

await databaseClient.getCandidatePendingTasks(); // [...]