Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Pool

A connection pool which reuses a number of SQL connections.

Hierarchy

Index

Methods

close

  • close(): PromiseLike<void>
  • close(handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • Close the pool and release the associated resources.

    Returns PromiseLike<void>

  • Close the pool and release the associated resources.

    Parameters

    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns void

connectHandler

  • Set an handler called when the pool has established a connection to the database.

    This handler allows interactions with the database before the connection is added to the pool.

    When the handler has finished, it must call {@link SqlClient#close} to release the connection to the pool.

    Parameters

    Returns Pool

connectionProvider

  • Replace the default pool connection provider, the new provider returns a future connection for a given .

    A {@link ConnectionFactory} can be used as connection provider.

    Parameters

    Returns Pool

getConnection

  • Get a connection from the pool.

    Returns PromiseLike<SqlConnection>

  • Get a connection from the pool.

    Parameters

    Returns void

preparedQuery

  • A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.

    Parameters

    • sql: string

    Returns PreparedQuery<RowSet<Row>>

query

  • A connection is borrowed from the connection pool when the query is executed and then immediately returned to the pool after it completes.

    Parameters

    • sql: string

    Returns Query<RowSet<Row>>

size

  • size(): number
  • Returns number

withConnection

  • withConnection<T>(__function: (arg: SqlConnection) => PromiseLike<T>): PromiseLike<T>
  • withConnection<T>(__function: (arg: SqlConnection) => PromiseLike<T>, handler: ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>): void
  • Get a connection from the pool and execute the given function.

    When the future returned by the function completes, the connection is returned to the pool.

    The handler is given a success result when the function returns a succeeded futures. Otherwise it is given a failure result.

    Type parameters

    • T

    Parameters

    Returns PromiseLike<T>

  • Get a connection from the pool and execute the given function.

    When the future returned by the function completes, the connection is returned to the pool.

    The handler is given a success result when the function returns a succeeded futures. Otherwise it is given a failure result.

    Type parameters

    • T

    Parameters

    • __function: (arg: SqlConnection) => PromiseLike<T>
    • handler: ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

    Returns void

withTransaction

  • withTransaction<T>(__function: (arg: SqlConnection) => PromiseLike<T>): PromiseLike<T>
  • withTransaction<T>(__function: (arg: SqlConnection) => PromiseLike<T>, handler: ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>): void
  • withTransaction<T>(txPropagation: TransactionPropagation, __function: (arg: SqlConnection) => PromiseLike<T>): PromiseLike<T>
  • withTransaction<T>(txPropagation: TransactionPropagation, __function: (arg: SqlConnection) => PromiseLike<T>, handler: ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>): void
  • Execute the given function within a transaction.

    The function is passed a client executing all operations within a transaction. When the future returned by the function

    • succeeds the transaction commits
    • fails the transaction rollbacks

    The handler is given a success result when the function returns a succeeded futures and the transaction commits. Otherwise it is given a failure result.

    Type parameters

    • T

    Parameters

    Returns PromiseLike<T>

  • Execute the given function within a transaction.

    The function is passed a client executing all operations within a transaction. When the future returned by the function

    • succeeds the transaction commits
    • fails the transaction rollbacks

    The handler is given a success result when the function returns a succeeded futures and the transaction commits. Otherwise it is given a failure result.

    Type parameters

    • T

    Parameters

    • __function: (arg: SqlConnection) => PromiseLike<T>
    • handler: ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

    Returns void

  • Like {@link Pool#withTransaction} but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.

    Type parameters

    • T

    Parameters

    Returns PromiseLike<T>

  • Like {@link Pool#withTransaction} but allows for setting the mode, defining how the acquired connection is managed during the execution of the function.

    Type parameters

    • T

    Parameters

    • txPropagation: TransactionPropagation
    • __function: (arg: SqlConnection) => PromiseLike<T>
    • handler: ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

    Returns void

Generated using TypeDoc