import { createRequire } from "node:module";
const _require = createRequire(import.meta.url);
class BunStore {
  db;
  constructor(dbPath) {
    const { Database } = _require("bun:sqlite");
    this.db = new Database(dbPath, { create: true });
    this.pragma("journal_mode = WAL");
    this.pragma("busy_timeout = 5000");
    this.pragma("foreign_keys = ON");
  }
  exec(sql) {
    this.db.exec(sql);
  }
  prepare(sql) {
    const stmt = this.db.prepare(sql);
    return {
      run: (...args) => stmt.run(...args),
      get: (...args) => stmt.get(...args),
      all: (...args) => stmt.all(...args)
    };
  }
  pragma(pragma) {
    this.db.exec(`PRAGMA ${pragma}`);
  }
  inTransaction(fn) {
    const tx = this.db.transaction(fn);
    return tx();
  }
  close() {
    this.db.close();
  }
}
export {
  BunStore
};
