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

    Interface SQLBatchOptions<C>

    Controls whether an adapter may run a SQLDatabase.runBatch group inside one transaction, and on which connection.

    A transaction is only correct when every statement in it, BEGIN and COMMIT included, travels down the same connection. A pool does not guarantee that, and a pool cannot be told apart from a single connection by inspection: pg's Client and Pool both expose connect(), and any of them can be wrapped in something that exposes only query(). So the adapter never guesses. It batches when it recognizes a pool it knows how to lease from, when you hand it a SQLBatchOptions.lease of your own, or when you state that the handle is a single connection. Otherwise statements run one at a time, exactly as before.

    1.4.0

    interface SQLBatchOptions<C = unknown> {
        lease?: () => Promise<LeasedConnection<C>>;
        singleConnection?: boolean;
    }

    Type Parameters

    • C = unknown
    Index
    lease?: () => Promise<LeasedConnection<C>>

    Leases a dedicated connection for one batch. Takes precedence over SQLBatchOptions.singleConnection and over pool autodetection, and is the escape hatch for a handle CollegeDB does not recognize.

    singleConnection?: boolean

    Declares that the handle is one dedicated connection, so BEGIN/COMMIT can be issued straight through it. Set this for a pg.Client, a mysql2 connection, or any SQLite handle. Do not set it for a pool.