import {ILevelDbControllerMetrics} from "./metrics.js"; /** Shortcut for Uint8Array based IDatabaseController */ export type Db = IDatabaseController; export interface IDatabaseOptions { name: string; } export interface IFilterOptions { gt?: K; gte?: K; lt?: K; lte?: K; reverse?: boolean; limit?: number; /** For metrics */ bucketId?: string; } export type DbReqOpts = { /** For metrics */ bucketId?: string; }; export interface IKeyValue { key: K; value: V; } export interface IDatabaseController { // service start / stop start(): Promise; stop(): Promise; /** To inject metrics after CLI initialization */ setMetrics(metrics: ILevelDbControllerMetrics): void; // Core API get(key: K, opts?: DbReqOpts): Promise; put(key: K, value: V, opts?: DbReqOpts): Promise; delete(key: K, opts?: DbReqOpts): Promise; // Batch operations batchPut(items: IKeyValue[], opts?: DbReqOpts): Promise; batchDelete(keys: K[], opts?: DbReqOpts): Promise; // Iterate over entries keysStream(opts?: IFilterOptions): AsyncIterable; keys(opts?: IFilterOptions): Promise; valuesStream(opts?: IFilterOptions): AsyncIterable; values(opts?: IFilterOptions): Promise; entriesStream(opts?: IFilterOptions): AsyncIterable>; entries(opts?: IFilterOptions): Promise[]>; }