You've already forked obsidian-visualiser
Migration to Nuxt v4 file structure and dependencies update
This commit is contained in:
22
app/composables/useDatabase.ts
Normal file
22
app/composables/useDatabase.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
import { BunSQLiteDatabase, drizzle } from "drizzle-orm/bun-sqlite";
|
||||
import * as schema from '../db/schema';
|
||||
|
||||
let instance: BunSQLiteDatabase<typeof schema> & {
|
||||
$client: Database;
|
||||
};
|
||||
export default function useDatabase()
|
||||
{
|
||||
if(!instance)
|
||||
{
|
||||
const database = useRuntimeConfig().database;
|
||||
const sqlite = new Database(database);
|
||||
instance = drizzle({ client: sqlite, schema, /* logger: true */ });
|
||||
|
||||
instance.run("PRAGMA journal_mode = WAL;");
|
||||
instance.run("PRAGMA foreign_keys = true;");
|
||||
instance.run("PRAGMA optimize=0x10002;");
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
Reference in New Issue
Block a user