UNPKG

react-indexeddb-kit

Version:

A TypeScript-based React IndexedDB wrapper with CRUD operations.

41 lines (40 loc) 1.15 kB
export type FieldType = "string" | "number" | "boolean" | "date" | "object" | "array"; export interface FieldDefinition { type: FieldType; required?: boolean; unique?: boolean; default?: any; references?: { model: string; field: string; }; } export interface ModelDefinition { name: string; fields: Record<string, FieldDefinition>; } export interface Schema { models: ModelDefinition[]; } export interface QueryOptions { where?: Record<string, any>; include?: string[]; orderBy?: { field: string; direction: "asc" | "desc"; }; skip?: number; limit?: number; select?: Record<string, true>; } export interface ReactIndexDBClientProps { connect: () => Promise<void>; model: (name: string) => ReactIndexDBModelProps; } export interface ReactIndexDBModelProps { create: (data: Record<string, any>) => Promise<any>; findMany: (options?: QueryOptions) => Promise<any[]>; findUnique: (id: any, options?: QueryOptions) => Promise<any>; update: (id: any, data: Record<string, any>) => Promise<any>; delete: (id: any) => Promise<void>; }