part ok
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import * as SQLite from 'expo-sqlite';
|
||||
import type { SQLiteDatabase } from 'expo-sqlite';
|
||||
import { migrateDatabase } from './migrations';
|
||||
import { DATABASE_NAME } from './schema';
|
||||
|
||||
let database: SQLiteDatabase | null = null;
|
||||
|
||||
async function loadSqlite(): Promise<typeof import('expo-sqlite')> {
|
||||
return import('expo-sqlite');
|
||||
}
|
||||
|
||||
export async function getDatabase(): Promise<SQLiteDatabase> {
|
||||
if (database) return database;
|
||||
|
||||
const SQLite = await loadSqlite();
|
||||
const db = await SQLite.openDatabaseAsync(DATABASE_NAME);
|
||||
await migrateDatabase(db);
|
||||
database = db;
|
||||
|
||||
Reference in New Issue
Block a user