UNPKG

milodb

Version:

Fast encrypted JSON database with AI-friendly API

40 lines (39 loc) 1.47 kB
export interface Record { id: string | number; [key: string]: any; } export interface QueryOptions { limit?: number; offset?: number; sort?: string; order?: 'asc' | 'desc'; } export interface BatchResult { success: number; failed: number; errors: string[]; } export declare class MiloDB { private dbPath; private encryptor?; private indexCache; constructor(dbPath?: string, encryptionKey?: string); createTable(tableName: string): Promise<void>; insert(tableName: string, record: Record): Promise<Record>; insertMany(tableName: string, records: Record[]): Promise<BatchResult>; findById(tableName: string, id: string | number): Promise<Record | null>; find(tableName: string, query?: Partial<Record>, options?: QueryOptions): Promise<Record[]>; update(tableName: string, id: string | number, updates: Partial<Record>): Promise<Record | null>; updateMany(tableName: string, query: Partial<Record>, updates: Partial<Record>): Promise<number>; delete(tableName: string, id: string | number): Promise<boolean>; deleteMany(tableName: string, query: Partial<Record>): Promise<number>; count(tableName: string, query?: Partial<Record>): Promise<number>; dropTable(tableName: string): Promise<void>; listTables(): Promise<string[]>; private readTable; private writeTable; private getIndex; private invalidateIndex; private getTablePath; } export default MiloDB;