forked from jsnbuchanan/crowd-funder-for-time-pwa
fix problem with initialization & refactor types
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user