UNPKG

dead-simple-orm

Version:

A simple ORM package.

46 lines 1.55 kB
export type ColumnType = "text" | "long text" | "image" | "date" | "json" | "number" | "bool" | { type: "one-to-one" | "one-to-many"; ref: string; }; export type TableDeclaration = { [key: string]: ColumnType; }; export type DatabaseDeclaration = Record<string, TableDeclaration>; export type RawDbRecord = { id: string; metadata: string; createdAt: number; updatedAt: number; [key: string]: string | RawDbRecord[] | RawDbRecord | number | boolean; }; export type DbRecord = { id: string; metadata: Record<string, any>; createdAt: Date; updatedAt: Date; [key: string]: string | DbRecord[] | DbRecord | number | boolean | Date | Record<string, any>; }; export type GenericDB = { query: (sql: string, ...params: any[]) => { all: () => Promise<any[]>; get: (id: string) => any; run: (...params: any[]) => void; }; close: () => void; }; export declare class SimpleORM { private db; private declaration; constructor(db: GenericDB, declaration: DatabaseDeclaration); private checkAndRunMigrations; private initializeTables; private findReferenceFields; private updateReferenceOwner; private fetchRelations; get(id: string, fetchRelations?: boolean): Promise<DbRecord>; list(tableName: string, fetchRelations?: boolean): Promise<DbRecord[]>; delete(id: string): Promise<void>; insert(tableName: string, data: any): Promise<DbRecord>; update(record: any): Promise<DbRecord>; } //# sourceMappingURL=simpleOrm.d.ts.map