local-fake-api
Version:
A simple async local mock API without backend.
10 lines (9 loc) • 643 B
TypeScript
import { TApiResponse, TApiListResponse } from "../types";
export declare function createIndexedDbApi<T extends object>(tableName: string, primaryKey?: keyof T): {
list: (filter?: Partial<T>) => Promise<TApiListResponse<T>>;
get: (keyValue: string, keyName?: keyof T) => Promise<TApiResponse<T | null>>;
create: (item: T, uniqKey?: keyof T) => Promise<TApiResponse<T>>;
delete: (keyValue: string, keyName?: keyof T) => Promise<TApiResponse<void>>;
update: (keyValue: string, updates: Partial<T>, uniqKey?: keyof T) => Promise<TApiResponse<T | null>>;
deleteAll: (filter?: Partial<T>) => Promise<TApiResponse<void>>;
};