export interface ISQLiteAPIOptions { /** 指定 sqlite 二级制文件位置 * @url https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#new-databasepath-options */ nativeBinding?: string /** 是否以只读模式打开数据库 */ readonly?: boolean /** 是否开启安全模式 * 相当于 `synchronous = EXTRA` */ safeMode?: boolean /** 是否开启快速模式 * 相当于 `synchronous = OFF` * `journal_mode = WAL` */ fastMode?: boolean } export type ISQLiteAPIFactory = ( dbPath: string | Buffer, options?: ISQLiteAPIOptions ) => T export interface ISQLiteAPI { prepare: (sql: string) => Statement exec: (sql: string) => void close: () => void pragma: (command: string) => any transaction: (fn: (...args: any[]) => any) => any function: (name: string, fn: (...args: any[]) => any) => void loadExtension: (extension: string) => any serialize: () => Buffer } // -------------------- export interface RunResult { changes: number lastInsertRowid: number | bigint } export interface Statement { run(...params: any[]): RunResult get(...params: any[]): any | undefined all(...params: any[]): any[] iterate(...params: any[]): IterableIterator }