auto make db
This commit is contained in:
parent
6f3f68d0a4
commit
14bfbc2d5c
16
main.ts
16
main.ts
@ -22,6 +22,22 @@ interface Db {
|
||||
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 {
|
||||
private db = new sqlite.Database("bunker.db", { create: false });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user