@earth-app/collegedb
    Preparing search index...

    Interface SQLDatabase

    Provider-agnostic SQL database contract.

    interface SQLDatabase {
        atomicBatch?: boolean;
        consistency?: ConsistencyCapabilities;
        dialect?: SQLDialect;
        prepare(sql: string): PreparedStatement;
        runBatch?<T = Record<string, unknown>>(
            statements: BatchStatement[],
        ): Promise<QueryResult<T>[]>;
        withSession?(constraintOrBookmark?: string): SQLSession;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    • Executes several statements against this shard in one round trip.

      Optional. The provider adapters implement it over D1's native batch, Drizzle's db.batch, or a single driver transaction. CollegeDB falls back to sequential prepare().run() calls when a provider does not implement it, so callers never need to check for it.

      Named runBatch rather than batch on purpose: a raw D1Database is structurally assignable to this contract, and D1 already has a batch that takes prepared statements rather than SQL text. Reusing the name would make env.DB stop satisfying SQLDatabase.

      Statements execute in order and share one transaction per shard. There is no cross-shard atomicity: a routed batch spanning three shards is three independent transactions.

      Type Parameters

      • T = Record<string, unknown>

      Parameters

      Returns Promise<QueryResult<T>[]>

      1.3.0

    • Starts a read session. A raw D1 binding already has this method, and that is how CollegeDB detects it.

      The argument is first-primary, first-unconstrained or a bookmark string.

      Parameters

      • OptionalconstraintOrBookmark: string

      Returns SQLSession

      1.4.0

    atomicBatch?: boolean

    Whether SQLDatabase.runBatch rolls the whole group back when one statement fails.

    Optional, and true only for an adapter whose rollback has been shown to work. The journal cutover and the key lock refuse a shard that leaves it unset with MIGRATION_NO_ATOMIC_BATCH, because a batch that leaves its early statements behind would leave a tombstone beside a live row.

    1.4.0

    Which ReadConsistency modes this shard can honor.

    Optional. The Postgres, MySQL, MariaDB, SQLite and Drizzle adapters report primary and eventual and not session. A shard that leaves it unset is read as supporting session only when it has SQLDatabase.withSession.

    1.4.0

    dialect?: SQLDialect

    Which SQL dialect this shard speaks, so generated statements quote identifiers correctly.

    Optional. The adapter factories set it; a raw binding passed straight to initialize leaves it unset, which is read as ANSI double quoting and is correct for D1 and SQLite.

    1.3.0