28 lines
991 B
TypeScript
28 lines
991 B
TypeScript
// Minimal structural types for the better-sqlite3 surface the server uses.
|
|
// better-sqlite3 ships no type declarations (and no @types is installed), so
|
|
// this covers just the prepare/get/run/all/transaction/exec/pragma calls the
|
|
// migrated server modules make. Row shapes stay `any` — the queries are dynamic
|
|
// and each caller narrows what it reads. Shared so every migrated service reuses
|
|
// one `Db` type instead of redeclaring it.
|
|
|
|
export interface RunResult {
|
|
changes: number;
|
|
lastInsertRowid: number | bigint;
|
|
}
|
|
|
|
export interface Statement {
|
|
get(...params: unknown[]): any;
|
|
run(...params: unknown[]): RunResult;
|
|
all(...params: unknown[]): any[];
|
|
iterate(...params: unknown[]): IterableIterator<any>;
|
|
pluck(toggle?: boolean): Statement;
|
|
}
|
|
|
|
export interface Db {
|
|
prepare(sql: string): Statement;
|
|
transaction<T extends (...args: any[]) => any>(fn: T): T;
|
|
exec(sql: string): void;
|
|
pragma(source: string, options?: { simple?: boolean }): any;
|
|
close(): void;
|
|
}
|