knd-db
v1.0.5
Published
Library created to help connect to the Oracle database
Downloads
15
Readme
Description
Library created to help connect to the Oracle database
Installation
npm i knd-db --save
Usage
const getConnection = require('knd-db')
const sql = `
SELECT VALUES
FROM TABLE_NAME
WHERE COLUMN_NAME = :PARAM_A
AND COLUMN_NAME_2 = :PARAM_B
`
const binds = {
PARAM_A: {val:'YOUR_VALUE', dir:'IN'},
PARAM_B: {val:'YOUR_VALUE', dir:'IN'}
}
// Bind default direction is 'IN', most values 'OUT' or 'INOUT'
// Possible pass bind value PARAM_A: 'YOUR_VALUE', when using direction with default value
const test = async () => {
const connection = await getConnection()
try {
const result = await connection.execute( sql, connection.createOracleBinds(binds) )
// result.rows = array[{...},{...},...]
// await connection.commit() --> use for transactions actions
} catch (error) {
// await connection.rollback() --> use for transactions actions
throw new Error(error)
} finally {
await connection.close()
}
}
// built-in function to search the next sequence value by name
let id = await con.nextSequenceId('SEQUENCE_NAME')