fix: ensure data dir exists before loading db

This commit is contained in:
Rdeisenroth 2025-11-06 20:38:12 +01:00
parent 9a8d7a36b9
commit e3ae12107d
No known key found for this signature in database
GPG key ID: 197008FA42DE7127
2 changed files with 2 additions and 3 deletions

View file

@ -1,5 +1,7 @@
import { mkdir } from "node:fs/promises";
import { Database } from "bun:sqlite";
mkdir("./data", { recursive: true }).catch(console.error);
const db = new Database("./data/mydb.sqlite", { create: true });
if (!db.query("SELECT * FROM sqlite_master WHERE type='table'").get()) {