no crear muchas instancias de db

This commit is contained in:
Cat /dev/Nulo 2024-04-04 22:59:46 -03:00
parent cf52da7445
commit 0439218644

View file

@ -8,6 +8,7 @@ import { migrateDb } from "./migrate.js";
/** @type {null | import("drizzle-orm/better-sqlite3").BetterSQLite3Database<schema>} */
let db = null;
export function getDb() {
if (db) return db;
const sqlite = new Database(DB_PATH);
db = drizzle(sqlite, { schema, logger: true });
migrateDb(db);