Home Reference Source

Function

Static Public Summary
public

async connection(opts: object, fn: function): *

public

async resultSet(conn: Connection, sql: string, bind: array | object, opts: object, fn: function): *

public

async select(conn: Connection, sql: string, bind: array | object, opts: object): Results

Static Public

public async connection(opts: object, fn: function): * source

import {connection} from 'oracledb-with'

Params:

NameTypeAttributeDescription
opts object

The options passed directly to oracledb.getConnection(...)

fn function

The async function to run with the acquired connection

Return:

*

Example:

import witho from 'oracle-with'
await witho.conn({connectString: '...', ...}, async conn => {
  await conn.execute(...)
})

public async resultSet(conn: Connection, sql: string, bind: array | object, opts: object, fn: function): * source

import {resultSet} from 'oracledb-with'

Params:

NameTypeAttributeDescription
conn Connection

The Oracle connection

sql string

The SQL to run

bind array | object

The bind parameters

opts object

The options passed directly to oracleConn.execute(...)

fn function

The async function (resultSet, results) => {...} to run

Return:

*

Example:

import witho from 'oracle-with'
witho.resultSet(conn, 'SELECT * FROM ...', [], {outFormat: oracledb.OBJECT}, async (resultSet, results) => {
  await resultSet.getRow()
  // use: results.metaData
})
// or use on an existing connection:
await witho.conn({connectString: '...', ...}, async conn => {
  await conn.resultSet(sql, bind, opts, async resultSet => {
    // ...
  })
})

public async select(conn: Connection, sql: string, bind: array | object, opts: object): Results source

import {select} from 'oracledb-with'

Params:

NameTypeAttributeDescription
conn Connection

The Oracle connection

sql string

The SQL to run

bind array | object

The bind parameters

opts object

The options passed directly to oracleConn.execute(...)

Return:

Results

Returns the results returned from oracledb.execute(...), with .rows pre-populated from the complete resultSet

Example:

witho.select(conn, 'SELECT * FROM ...')
// => Promise<OracleResult {
//      ...
//      metaData: ...,
//      rows: [...],
//      ...
//    }>