preact-missing-hooks
Version:
A lightweight, extendable collection of missing React-like hooks for Preact — plus fresh, powerful new ones designed specifically for modern Preact apps.
21 lines (20 loc) • 1.35 kB
TypeScript
/**
* Table controller: insert, update, delete, exists, query, upsert, bulkInsert, clear, count.
* Works in standalone mode (opens its own transaction per op) or bound to a transaction.
* @module indexedDB/tableController
*/
import type { OperationCallbacks } from "./types";
/** Public interface for a table controller (standalone or transaction-scoped). */
export interface ITableController {
insert<T>(data: T, options?: OperationCallbacks<IDBValidKey>): Promise<IDBValidKey>;
update<T>(key: IDBValidKey, updates: Partial<T>, options?: OperationCallbacks<void>): Promise<void>;
delete(key: IDBValidKey, options?: OperationCallbacks<void>): Promise<void>;
exists(key: IDBValidKey): Promise<boolean>;
query<T>(filterFn: (item: T) => boolean, options?: OperationCallbacks<T[]>): Promise<T[]>;
upsert<T>(data: T, options?: OperationCallbacks<IDBValidKey>): Promise<IDBValidKey>;
bulkInsert<T>(items: T[], options?: OperationCallbacks<IDBValidKey[]>): Promise<IDBValidKey[]>;
clear(options?: OperationCallbacks<void>): Promise<void>;
count(options?: OperationCallbacks<number>): Promise<number>;
}
export declare function createTableController(db: IDBDatabase, tableName: string): ITableController;
export declare function createTransactionTableController(tx: IDBTransaction, tableName: string): ITableController;