Skip to content

Class: Pool ​

Defined in: packages/core/src/pool/pool.ts:66

A pool of Firebird connections. Each pooled connection is a full Attachment with its own statement cache, so warm statements survive across acquire/release cycles for a given physical connection — unless statementCache: 'clear-on-release' opts out (DDL-friendly mode). Acquire is LIFO (most recently released first), so the warmest cache is always the one handed out next.

Constructors ​

Constructor ​

ts
new Pool(options): Pool;

Defined in: packages/core/src/pool/pool.ts:80

Parameters ​

ParameterType
optionsPoolOptions

Returns ​

Pool

Methods ​

[asyncDispose]() ​

ts
asyncDispose: Promise<void>;

Defined in: packages/core/src/pool/pool.ts:302

await using pool = await createPool(…) → closes at scope exit.

Returns ​

Promise<void>


acquire() ​

ts
acquire(): Promise<Attachment>;

Defined in: packages/core/src/pool/pool.ts:143

Borrow a connection. Remember to release it (prefer use).

Returns ​

Promise<Attachment>


clearStatementCaches() ​

ts
clearStatementCaches(): Promise<void>;

Defined in: packages/core/src/pool/pool.ts:229

Clear the statement cache on every pooled connection. Idle connections release their server handles immediately (one ping each, in parallel); in-use connections clear lazily — their deferred frees ride the next packet they send. Call before DDL (recreate table, drop, alter) on objects the pool has queried, or the DDL fails with "object ... is in use" (cached prepared statements pin table metadata).

Returns ​

Promise<void>


close() ​

ts
close(): Promise<void>;

Defined in: packages/core/src/pool/pool.ts:307

Close every connection and reject pending waiters.

Returns ​

Promise<void>


execute() ​

ts
execute(sql, params?): Promise<number>;

Defined in: packages/core/src/pool/pool.ts:288

Parameters ​

ParameterTypeDefault value
sqlstringundefined
paramsQueryParams[]

Returns ​

Promise<number>


executeBatch() ​

ts
executeBatch(
   sql, 
   rows, 
options?): Promise<BatchResult>;

Defined in: packages/core/src/pool/pool.ts:293

Bulk DML via the wire batch API on a borrowed connection (see Attachment.executeBatch).

Parameters ​

ParameterType
sqlstring
rowsBatchRows
options?BatchOptions

Returns ​

Promise<BatchResult>


map() ​

ts
map<T, R>(
   items, 
   fn, 
opts?): Promise<R[]>;

Defined in: packages/core/src/pool/pool.ts:256

Run fn over items across pooled connections with bounded concurrency (default = pool max), returning results in input order. Each call gets its own borrowed connection, so this is the way to do genuinely parallel work — e.g. partition a large query by key range and fetch each partition (including its blobs) concurrently.

NOTE: a lazy Blob handle is bound to the connection + transaction that produced it and cannot be read on another connection, so you cannot fan a single result set's blob handles across the pool — run the query per partition inside fn instead.

Type Parameters ​

Type Parameter
T
R

Parameters ​

ParameterType
itemsreadonly T[]
fn(conn, item, index) => Promise<R>
opts{ concurrency?: number; }
opts.concurrency?number

Returns ​

Promise<R[]>


query() ​

ts
query<T>(sql, params?): Promise<T[]>;

Defined in: packages/core/src/pool/pool.ts:275

Type Parameters ​

Type ParameterDefault type
TRow

Parameters ​

ParameterTypeDefault value
sqlstringundefined
paramsQueryParams[]

Returns ​

Promise<T[]>


queryOne() ​

ts
queryOne<T>(sql, params?): Promise<T | undefined>;

Defined in: packages/core/src/pool/pool.ts:280

First row or undefined (see Attachment.queryOne).

Type Parameters ​

Type ParameterDefault type
TRow

Parameters ​

ParameterTypeDefault value
sqlstringundefined
paramsQueryParams[]

Returns ​

Promise<T | undefined>


release() ​

ts
release(conn): void;

Defined in: packages/core/src/pool/pool.ts:195

Return a borrowed connection to the pool (or discard if unhealthy).

Parameters ​

ParameterType
connAttachment

Returns ​

void


run() ​

ts
run<T>(sql, params?): Promise<QueryResult<T>>;

Defined in: packages/core/src/pool/pool.ts:284

Type Parameters ​

Type ParameterDefault type
TRow

Parameters ​

ParameterTypeDefault value
sqlstringundefined
paramsQueryParams[]

Returns ​

Promise<QueryResult<T>>


stats() ​

ts
stats(): PoolStats;

Defined in: packages/core/src/pool/pool.ts:94

Returns ​

PoolStats


transaction() ​

ts
transaction<T>(fn, options?): Promise<T>;

Defined in: packages/core/src/pool/pool.ts:297

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
fn(tx) => Promise<T>
options?TransactionOptions

Returns ​

Promise<T>


use() ​

ts
use<T>(fn): Promise<T>;

Defined in: packages/core/src/pool/pool.ts:235

Acquire → run fn → release (even on error). The safe default.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
fn(conn) => Promise<T>

Returns ​

Promise<T>


warmup() ​

ts
warmup(): Promise<void>;

Defined in: packages/core/src/pool/pool.ts:99

Warm the pool up to min connections. Optional — acquire is lazy anyway.

Returns ​

Promise<void>

MIT Licensed. Contains data derived from the Firebird project under IDPL/IPL.