2022-07-18 17:49:42 +02:00
|
|
|
import {RunResult, SqlType, Statement, TypedDatabase} from "../database";
|
|
|
|
import * as sqlite3 from "sqlite3";
|
2020-06-30 01:10:18 +02:00
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export async function init(): Promise<void> {
|
|
|
|
}
|
2020-06-30 01:10:18 +02:00
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export class MockDatabase implements TypedDatabase {
|
|
|
|
constructor() {
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async on(event: string, listener: any): Promise<void> {
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async run(sql: SqlType, ...params: any[]): Promise<RunResult> {
|
|
|
|
return {
|
|
|
|
stmt: new Statement(new sqlite3.Statement()),
|
|
|
|
};
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async get<T = any>(sql: SqlType, ...params: any[]): Promise<T | undefined> {
|
|
|
|
return undefined;
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async each<T = any>(sql: SqlType, callback: (err: any, row: T) => void): Promise<number>;
|
|
|
|
async each<T = any>(sql: SqlType, param1: any, callback: (err: any, row: T) => void): Promise<number>;
|
|
|
|
async each<T = any>(sql: SqlType, param1: any, param2: any, callback: (err: any, row: T) => void): Promise<number>;
|
|
|
|
async each<T = any>(sql: SqlType, param1: any, param2: any, param3: any, callback: (err: any, row: T) => void): Promise<number>;
|
|
|
|
async each<T = any>(sql: SqlType, ...params: any[]): Promise<number>;
|
|
|
|
async each(sql: SqlType, ...callback: (any)[]): Promise<number> {
|
|
|
|
return 0;
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async all<T>(sql: SqlType, ...params: any[]): Promise<T[]> {
|
2020-06-30 01:10:18 +02:00
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async exec(sql: SqlType, ...params: any[]): Promise<void> {
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
async prepare(sql: SqlType, ...params: any[]): Promise<Statement> {
|
|
|
|
return new Statement(new sqlite3.Statement());
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const db: MockDatabase = new MockDatabase();
|
|
|
|
|
2022-07-18 17:49:42 +02:00
|
|
|
export {TypedDatabase, Statement}
|