import { StatementCache } from "../../../zqlite/src/internal/statement-cache.js";
class StatementRunner {
  db;
  statementCache;
  constructor(db) {
    this.db = db;
    this.statementCache = new StatementCache(db);
  }
  /**
   * Prepares a statement (or retrieves it from the cache) and runs it
   * with the given args.
   */
  run(sql, ...args) {
    return this.statementCache.use(
      sql,
      (cached) => cached.statement.run(...args)
    );
  }
  /**
   * Prepares a statement (or retrieves it from the cache) and returns
   * the first result.
   */
  // oxlint-disable-next-line @typescript-eslint/no-explicit-any
  get(sql, ...args) {
    return this.statementCache.use(
      sql,
      (cached) => cached.statement.get(...args)
    );
  }
  /**
   * Prepares a statement (or retrieves it from the cache) and returns
   * all of its results.
   */
  // oxlint-disable-next-line @typescript-eslint/no-explicit-any
  all(sql, ...args) {
    return this.statementCache.use(
      sql,
      (cached) => cached.statement.all(...args)
    );
  }
  // Syntactic sugar methods
  begin() {
    return this.run("BEGIN");
  }
  beginConcurrent() {
    return this.run("BEGIN CONCURRENT");
  }
  beginImmediate() {
    return this.run("BEGIN IMMEDIATE");
  }
  commit() {
    return this.run("COMMIT");
  }
  rollback() {
    return this.run("ROLLBACK");
  }
}
export {
  StatementRunner
};
//# sourceMappingURL=statements.js.map
