@photostructure/sqlite
    Preparing search index...

    Interface EnhancedMethods

    Interface for an enhanced database with pragma() and transaction() methods.

    interface EnhancedMethods {
        pragma(source: string, options?: PragmaOptions): unknown;
        transaction<F extends (...args: any[]) => any>(
            fn: F,
        ): TransactionFunction<F>;
    }
    Index

    Methods

    • Executes a PRAGMA statement and returns its result.

      Parameters

      • source: string

        The PRAGMA command (without "PRAGMA" prefix)

      • Optionaloptions: PragmaOptions

        Optional configuration

      Returns unknown

      Array of rows, or single value if simple: true

      db.pragma('cache_size', { simple: true }); // -16000
      db.pragma('journal_mode = wal');
    • Creates a function that always runs inside a transaction.

      Type Parameters

      • F extends (...args: any[]) => any

      Parameters

      • fn: F

        The function to wrap in a transaction

      Returns TransactionFunction<F>

      A transaction function with .deferred, .immediate, .exclusive variants

      const insertMany = db.transaction((items) => {
      for (const item of items) insert.run(item);
      });
      insertMany(['a', 'b', 'c']); // All in one transaction