auto make db
Some checks failed
Integration / validate (push) Successful in 9s
Release / build (push) Failing after 10s

This commit is contained in:
SimonFJ20 2024-09-26 01:35:13 +02:00
parent 6f3f68d0a4
commit 14bfbc2d5c

16
main.ts
View File

@ -22,6 +22,22 @@ interface Db {
createSession(init: Omit<Session, "id">): Promise<Session>; createSession(init: Omit<Session, "id">): Promise<Session>;
} }
try {
await Deno.lstat("bunker.db");
} catch (error) {
if (!(error instanceof Deno.errors.NotFound)) {
throw error;
}
const cmd = new Deno.Command("sqlite3", {
args: ["bunker.db", ".read database.sql"],
stdout: "piped",
stderr: "piped",
});
console.log(
await cmd.output().then((out) => new TextDecoder().decode(out.stdout)),
);
}
class SqliteDb implements Db { class SqliteDb implements Db {
private db = new sqlite.Database("bunker.db", { create: false }); private db = new sqlite.Database("bunker.db", { create: false });