Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SQLConnection

Represents a connection to a SQL database

Hierarchy

  • SQLConnection

Implements

  • any

Index

Methods

batch

  • batch(sqlStatements: string): PromiseLike<number>
  • batch(sqlStatements: string, handler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): SQLConnection
  • Batch simple SQL strings and execute the batch where the async result contains a array of Integers.

    Parameters

    • sqlStatements: string

    Returns PromiseLike<number>

  • Batch simple SQL strings and execute the batch where the async result contains a array of Integers.

    Parameters

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

    Returns SQLConnection

batchCallableWithParams

  • batchCallableWithParams(sqlStatement: string, inArgs: any[], outArgs: any[]): PromiseLike<number>
  • batchCallableWithParams(sqlStatement: string, inArgs: any[], outArgs: any[], handler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): SQLConnection
  • Batch a callable statement with all entries from the args list. Each entry is a batch. The size of the lists inArgs and outArgs MUST be the equal. The operation completes with the execution of the batch where the async result contains a array of Integers.

    Parameters

    • sqlStatement: string
    • inArgs: any[]
    • outArgs: any[]

    Returns PromiseLike<number>

  • Batch a callable statement with all entries from the args list. Each entry is a batch. The size of the lists inArgs and outArgs MUST be the equal. The operation completes with the execution of the batch where the async result contains a array of Integers.

    Parameters

    • sqlStatement: string
    • inArgs: any[]
    • outArgs: any[]
    • handler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>

    Returns SQLConnection

batchWithParams

  • batchWithParams(sqlStatement: string, args: any[]): PromiseLike<number>
  • batchWithParams(sqlStatement: string, args: any[], handler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>): SQLConnection
  • Batch a prepared statement with all entries from the args list. Each entry is a batch. The operation completes with the execution of the batch where the async result contains a array of Integers.

    Parameters

    • sqlStatement: string
    • args: any[]

    Returns PromiseLike<number>

  • Batch a prepared statement with all entries from the args list. Each entry is a batch. The operation completes with the execution of the batch where the async result contains a array of Integers.

    Parameters

    • sqlStatement: string
    • args: any[]
    • handler: ((res: AsyncResult<number>) => void) | Handler<AsyncResult<number>>

    Returns SQLConnection

call

  • Calls the given SQL PROCEDURE which returns the result from the procedure.

    Parameters

    • sql: string

    Returns PromiseLike<ResultSet>

  • Calls the given SQL PROCEDURE which returns the result from the procedure.

    Parameters

    • sql: string
    • resultHandler: ((res: AsyncResult<ResultSet>) => void) | Handler<AsyncResult<ResultSet>>

    Returns SQLConnection

callWithParams

  • callWithParams(sql: string, params: any[], outputs: any[]): PromiseLike<ResultSet>
  • callWithParams(sql: string, params: any[], outputs: any[], resultHandler: ((res: AsyncResult<ResultSet>) => void) | Handler<AsyncResult<ResultSet>>): SQLConnection
  • Calls the given SQL PROCEDURE which returns the result from the procedure.

    The index of params and outputs are important for both arrays, for example when dealing with a prodecure that takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:

      params = [VALUE1, VALUE2, null]
      outputs = [null, null, "VARCHAR"]
    

    Parameters

    • sql: string
    • params: any[]
    • outputs: any[]

    Returns PromiseLike<ResultSet>

  • Calls the given SQL PROCEDURE which returns the result from the procedure.

    The index of params and outputs are important for both arrays, for example when dealing with a prodecure that takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:

      params = [VALUE1, VALUE2, null]
      outputs = [null, null, "VARCHAR"]
    

    Parameters

    • sql: string
    • params: any[]
    • outputs: any[]
    • resultHandler: ((res: AsyncResult<ResultSet>) => void) | Handler<AsyncResult<ResultSet>>

    Returns SQLConnection

close

  • close(): PromiseLike<void>
  • close(handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • close(): void
  • Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

    Returns PromiseLike<void>

  • Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

    Parameters

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

    Returns void

  • Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

    Returns void

commit

  • commit(): PromiseLike<void>
  • commit(handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): SQLConnection
  • Commits all changes made since the previous commit/rollback.

    Returns PromiseLike<void>

  • Commits all changes made since the previous commit/rollback.

    Parameters

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

    Returns SQLConnection

execute

  • execute(sql: string): PromiseLike<void>
  • execute(sql: string, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): SQLConnection
  • Executes the given SQL statement

    Parameters

    • sql: string

    Returns PromiseLike<void>

  • Executes the given SQL statement

    Parameters

    • sql: string
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns SQLConnection

getTransactionIsolation

  • Attempts to return the transaction isolation level for this Connection object to the one given.

    Returns PromiseLike<TransactionIsolation>

  • Attempts to return the transaction isolation level for this Connection object to the one given.

    Parameters

    Returns SQLConnection

query

  • Executes the given SQL SELECT statement which returns the results of the query.

    Parameters

    • sql: string

    Returns PromiseLike<ResultSet>

  • Executes the given SQL SELECT statement which returns the results of the query.

    Parameters

    • sql: string
    • resultHandler: ((res: AsyncResult<ResultSet>) => void) | Handler<AsyncResult<ResultSet>>

    Returns SQLConnection

querySingle

  • querySingle(sql: string): PromiseLike<any[]>
  • querySingle(sql: string, handler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): SQLOperations
  • Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

    Parameters

    • sql: string

    Returns PromiseLike<any[]>

  • Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

    Parameters

    • sql: string
    • handler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns SQLOperations

querySingleWithParams

  • querySingleWithParams(sql: string, arguments: any[]): PromiseLike<any[]>
  • querySingleWithParams(sql: string, arguments: any[], handler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>): SQLOperations
  • Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

    Parameters

    • sql: string
    • arguments: any[]

    Returns PromiseLike<any[]>

  • Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

    Parameters

    • sql: string
    • arguments: any[]
    • handler: ((res: AsyncResult<any[]>) => void) | Handler<AsyncResult<any[]>>

    Returns SQLOperations

queryStream

  • Executes the given SQL SELECT statement which returns the results of the query as a read stream.

    Parameters

    • sql: string

    Returns PromiseLike<SQLRowStream>

  • Executes the given SQL SELECT statement which returns the results of the query as a read stream.

    Parameters

    Returns SQLConnection

queryStreamWithParams

  • Executes the given SQL SELECT statement which returns the results of the query as a read stream.

    Parameters

    • sql: string
    • params: any[]

    Returns PromiseLike<SQLRowStream>

  • Executes the given SQL SELECT statement which returns the results of the query as a read stream.

    Parameters

    Returns SQLConnection

queryWithParams

  • queryWithParams(sql: string, params: any[]): PromiseLike<ResultSet>
  • queryWithParams(sql: string, params: any[], resultHandler: ((res: AsyncResult<ResultSet>) => void) | Handler<AsyncResult<ResultSet>>): SQLConnection
  • Executes the given SQL SELECT prepared statement which returns the results of the query.

    Parameters

    • sql: string
    • params: any[]

    Returns PromiseLike<ResultSet>

  • Executes the given SQL SELECT prepared statement which returns the results of the query.

    Parameters

    • sql: string
    • params: any[]
    • resultHandler: ((res: AsyncResult<ResultSet>) => void) | Handler<AsyncResult<ResultSet>>

    Returns SQLConnection

rollback

  • rollback(): PromiseLike<void>
  • rollback(handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): SQLConnection
  • Rolls back all changes made since the previous commit/rollback.

    Returns PromiseLike<void>

  • Rolls back all changes made since the previous commit/rollback.

    Parameters

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

    Returns SQLConnection

setAutoCommit

  • setAutoCommit(autoCommit: boolean): PromiseLike<void>
  • setAutoCommit(autoCommit: boolean, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): SQLConnection
  • Sets the auto commit flag for this connection. True by default.

    Parameters

    • autoCommit: boolean

    Returns PromiseLike<void>

  • Sets the auto commit flag for this connection. True by default.

    Parameters

    • autoCommit: boolean
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns SQLConnection

setOptions

  • Sets the desired options to be applied to the current connection when statements are executed.

    The options are not applied globally but applicable to the current connection. For example changing the transaction isolation level will only affect statements run on this connection and not future or current connections acquired from the connection pool.

    This method is not async in nature since the apply will only happen at the moment a query is run.

    Parameters

    Returns SQLConnection

setQueryTimeout

  • Sets a connection wide query timeout.

    It can be over written at any time and becomes active on the next query call.

    Parameters

    • timeoutInSeconds: number

    Returns SQLConnection

setTransactionIsolation

  • Attempts to change the transaction isolation level for this Connection object to the one given.

    The constants defined in the interface Connection are the possible transaction isolation levels.

    Parameters

    Returns PromiseLike<void>

  • Attempts to change the transaction isolation level for this Connection object to the one given.

    The constants defined in the interface Connection are the possible transaction isolation levels.

    Parameters

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

    Returns SQLConnection

update

  • Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

    Parameters

    • sql: string

    Returns PromiseLike<UpdateResult>

  • Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

    Parameters

    Returns SQLConnection

updateWithParams

  • Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters

    Parameters

    • sql: string
    • params: any[]

    Returns PromiseLike<UpdateResult>

  • Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters

    Parameters

    • sql: string
    • params: any[]
    • resultHandler: ((res: AsyncResult<UpdateResult>) => void) | Handler<AsyncResult<UpdateResult>>

    Returns SQLConnection

Generated using TypeDoc