import { createRequire } from "node:module";
const _require = createRequire(import.meta.url);
class NodeStore {
  db;
  constructor(dbPath) {
    const Database = _require("better-sqlite3");
    this.db = new Database(dbPath);
    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.pragma(pragma);
  }
  inTransaction(fn) {
    return this.db.transaction(fn)();
  }
  close() {
    this.db.close();
  }
}
export {
  NodeStore
};
