3.0.1 • Published 5 years ago

@ac-moore-inc/oracledb-wrapper v3.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

OracleDb Wrapper

An easy to use orabledb wrapper with pagination and large result support.

Created and maintained by the A.C. Moore software engineering team.

Methods

prepareService

Create the connection pools for provided databases

prepareService(config);

Parameters:

config: object

A configuration object containing information related to the database is required to connect. It is utilized by prepareService and close

config Example:
{
    databaseName: {
        'connectString': 'dbconnect',
        'poolMin': 4,
        'poolMax': 200,
        'poolIncrement': 4,
        'poolTimeout': 60,
        'user': 'db_user_name',
        'password': 'db_pass',
        'queueRequests': true,
        'queueTimeout': 0
    },
    other db connections...
}

getConnection

If connection is passed return same connection, otherwise create the connection

getConnection(databaseOrConnection, callback);

Parameters:

databaseOrConnection:

Pass the database name as a string or an existing connection


releaseConn

Releases the database connection

release(connection, info);

Parameters:

connection:

Reference to the established connection

info: string

Debugging information, will be logged if any error is encountered while releasing the connection


close

Closes the database connection pool

close(config, callback);

Parameters:

config:

See prepareService


selectQuery

Executes a select query to the database

executeQuery(options, callback);

Parameters:

options: object
FieldTypeRequiredValue
conndatabase connectiontruedatabase connection
dbstringtruedatabase name as defined in the config object used to prepare the service
qrydataobjectfalseobject containing query data, details below
flatQrystringfalsestring defining the query to be executed
bindvarsobject or arrayfalsedefines the bind variables for the query, details below
outFormatoracledb typefalsedefines the outformat of the query. defaults to oracledb.OBJECT
qrydata:
FieldTypeRequiredValue
fieldsstringtruefields to be retrieved in query
from_objectsstringtrueobjects to be queried
where_clausestringfalseadditional criteria for query
order_bystringfalsefield or fields to order results by
bindvars: object
FieldTypeRequiredValue
valvalue typefalsethe value being used in the package call, omitted if value is out bound
typeoracledb typefalsethe oracledb type of the value, only required if value is vartype
diroracledb.BIND_IN/BIND_OUT/BIND_INOUTfalsedefines if value is in bound, out bound, or both
bindvars object Example:
var bindvars = {
  I_EMPLOYEE_ID: {
      val: employeeId,
      type: oracledb.NUMBER,
      dir: oracledb.BIND_IN
  },
  O_ERROR_MESSAGE: {
      type: oracledb.STRING,
      dir: oracledb.BIND_OUT
  },
  v_Return: {
      type: oracledb.NUMBER,
      dir: oracledb.BIND_OUT
  }
};
bindvars: array

If the bind variables are simple values, they can be passed in an array

bindvars array Example:
var iemployee_id = employeeId
var iemployee_name = employeeName
var bindvars = [iemployee_id., iemployee_name];

executePkg

Executes a package call to the database

executePkg is also capible of executing select and update statements. Unlike selectQuery, executePkg is not optimized to retrieve large sets of data.

executePkg(options, callback);

If connection is passed in the options variable then query considered to be part of transaction and there will be no commit

If connection is not passed in the options variable then query considered to be a standalone query and there will be an autoCommit

Parameters:

options: object
FieldTypeRequiredValue
conndatabase connectiontruedatabase connection
dbstringtruedatabase name as defined in the config object used to prepare the service
qrystringfalsestring defining the package call to be executed
bindvarsobject or arrayfalsedefines the bind variables for the query, see executeQuery for exmaples

buildBindVariables

Builds bind variables object for package calls.

buildBindVariables(inputStructure, input);

Parameters:

inputStructure: Array
Elements: Field name, Type, Dir, Required(boolean)
Types Mapping:
SymbolValue
SString
NNumber
DDate
Dirs Mapping:
SymbolValue
IBIND_IN
OBIND_OUT
IOBIND_INOUT
inputStructure Example:
let inputStructure = [
  ['employee', 'S', 'I', true],
  ['salary', 'N', 'I', true],
  ['hire_date', 'D', 'I', false]
  ['entry_id', 'N', 'O'],
  ['error_message', 'S', 'O']
];
input: Object

The input object property names must match the field names in inputStructure

input Example:
let input = {
  employee: 'Sally Sales',
  salary: 100000,
  hire_date: '2017-03-17T17:47:08.000Z'
};
3.0.1

5 years ago

3.0.0

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago