mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-23 06:36:19 +00:00
no crear muchas instancias de db
This commit is contained in:
parent
cf52da7445
commit
0439218644
1 changed files with 1 additions and 0 deletions
|
@ -8,6 +8,7 @@ import { migrateDb } from "./migrate.js";
|
||||||
/** @type {null | import("drizzle-orm/better-sqlite3").BetterSQLite3Database<schema>} */
|
/** @type {null | import("drizzle-orm/better-sqlite3").BetterSQLite3Database<schema>} */
|
||||||
let db = null;
|
let db = null;
|
||||||
export function getDb() {
|
export function getDb() {
|
||||||
|
if (db) return db;
|
||||||
const sqlite = new Database(DB_PATH);
|
const sqlite = new Database(DB_PATH);
|
||||||
db = drizzle(sqlite, { schema, logger: true });
|
db = drizzle(sqlite, { schema, logger: true });
|
||||||
migrateDb(db);
|
migrateDb(db);
|
||||||
|
|
Loading…
Reference in a new issue