fix problem with initialization & refactor types

This commit is contained in:
2025-05-25 18:32:41 -06:00
parent 83771caee1
commit a3bdcfd168
3 changed files with 16 additions and 15 deletions

View File

@@ -6,8 +6,9 @@ declare module 'absurd-sql/dist/indexeddb-backend';
import initSqlJs from '@jlongster/sql.js';
import { SQLiteFS } from 'absurd-sql';
import IndexedDBBackend from 'absurd-sql/dist/indexeddb-backend';
import { runMigrations } from '../db-sql/migration';
import { QueryExecResult } from './migrationService';
import type { QueryExecResult } from '../interfaces/database';
interface SQLDatabase {
exec: (sql: string, params?: any[]) => Promise<QueryExecResult[]>;
@@ -73,12 +74,13 @@ class DatabaseService {
return this.db!.run(sql, params);
}
// Note that the resulting array may be empty if there are no results from the query
async query(sql: string, params: any[] = []): Promise<QueryExecResult[]> {
this.ensureInitialized();
return this.db!.exec(sql, params);
}
async get(sql: string, params: any[] = []): Promise<any[] | undefined> {
async getOneRow(sql: string, params: any[] = []): Promise<any[] | undefined> {
this.ensureInitialized();
const result = await this.db!.exec(sql, params);
return result[0]?.values[0];