import { Database } from "../../../zqlite/src/db.js";
import { StatementCache } from "../../../zqlite/src/internal/statement-cache.js";
/**
 * A stateless wrapper around a {@link StatementCache} that facilitates single-line
 * `printf()` style invocations of cached prepared statement operations.
 */
export 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');
    }
}
//# sourceMappingURL=statements.js.map