simple-oracledb
Advanced tools
Comparing version 1.1.23 to 1.1.24
154
docs/api.md
@@ -6,2 +6,4 @@ ## Classes | ||
<dd></dd> | ||
<dt><a href="#OracleDB">OracleDB</a></dt> | ||
<dd></dd> | ||
<dt><a href="#Pool">Pool</a></dt> | ||
@@ -697,2 +699,119 @@ <dd></dd> | ||
<a name="OracleDB"></a> | ||
## OracleDB | ||
**Kind**: global class | ||
**Access:** public | ||
**Author:** Sagie Gur-Ari | ||
* [OracleDB](#OracleDB) | ||
* [new OracleDB()](#new_OracleDB_new) | ||
* [.simplified](#OracleDB.simplified) : <code>boolean</code> | ||
* [#getConnection(connectionAttributes, [callback])](#OracleDB+getConnection) ⇒ <code>Promise</code> | ||
* [#createPool(poolAttributes, [callback])](#OracleDB+createPool) ⇒ <code>Promise</code> | ||
* _instance_ | ||
* ["pool-created" (pool)](#OracleDB+event_pool-created) | ||
* ["pool-released" (pool)](#OracleDB+event_pool-released) | ||
* ["connection-created" (connection)](#OracleDB+event_connection-created) | ||
* ["connection-released" (connection)](#OracleDB+event_connection-released) | ||
* _static_ | ||
* [.extend(oracledb)](#OracleDB.extend) | ||
<a name="new_OracleDB_new"></a> | ||
### new OracleDB() | ||
This class holds all the extended capabilities added the oracledb. | ||
<a name="OracleDB.simplified"></a> | ||
### OracleDB.simplified : <code>boolean</code> | ||
Marker property. | ||
**Access:** public | ||
<a name="OracleDB+getConnection"></a> | ||
### OracleDB#getConnection(connectionAttributes, [callback]) ⇒ <code>Promise</code> | ||
Wraps the original oracledb getConnection in order to provide an extended connection object. | ||
**Returns**: <code>Promise</code> - In case of no callback provided in input, this function will return a promise | ||
**Access:** public | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| connectionAttributes | <code>object</code> | The connection attributes object | | ||
| [callback] | <code>[AsyncCallback](#AsyncCallback)</code> | Invoked with an error or the oracle connection instance | | ||
<a name="OracleDB+createPool"></a> | ||
### OracleDB#createPool(poolAttributes, [callback]) ⇒ <code>Promise</code> | ||
Wraps the original oracledb createPool in order to provide an extended pool object. | ||
**Returns**: <code>Promise</code> - In case of no callback provided in input, this function will return a promise | ||
**Access:** public | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| poolAttributes | <code>object</code> | | The connection pool attributes object (see https://github.com/oracle/node-oracledb/blob/master/doc/api.md#createpool for more attributes) | | ||
| [poolAttributes.retryCount] | <code>number</code> | <code>10</code> | The max amount of retries to get a connection from the pool in case of any error | | ||
| [poolAttributes.retryInterval] | <code>number</code> | <code>250</code> | The interval in millies between get connection retry attempts | | ||
| [poolAttributes.runValidationSQL] | <code>boolean</code> | <code>true</code> | True to ensure the connection returned is valid by running a test validation SQL | | ||
| [poolAttributes.validationSQL] | <code>string</code> | <code>"SELECT 1 FROM DUAL"</code> | The test SQL to invoke before returning a connection to validate the connection is open | | ||
| [callback] | <code>[AsyncCallback](#AsyncCallback)</code> | | Invoked with an error or the oracle connection pool instance | | ||
<a name="OracleDB+event_pool-created"></a> | ||
### "pool-created" (pool) | ||
This events is triggered when a pool is created. | ||
**Kind**: event emitted by <code>[OracleDB](#OracleDB)</code> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| pool | <code>[Pool](#Pool)</code> | The pool instance | | ||
<a name="OracleDB+event_pool-released"></a> | ||
### "pool-released" (pool) | ||
This events is triggered after a pool is released. | ||
**Kind**: event emitted by <code>[OracleDB](#OracleDB)</code> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| pool | <code>[Pool](#Pool)</code> | The pool instance | | ||
<a name="OracleDB+event_connection-created"></a> | ||
### "connection-created" (connection) | ||
This events is triggered when a connection is created via oracledb. | ||
**Kind**: event emitted by <code>[OracleDB](#OracleDB)</code> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| connection | <code>[Connection](#Connection)</code> | The connection instance | | ||
<a name="OracleDB+event_connection-released"></a> | ||
### "connection-released" (connection) | ||
This events is triggered when a connection is released successfully. | ||
**Kind**: event emitted by <code>[OracleDB](#OracleDB)</code> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| connection | <code>[Connection](#Connection)</code> | The connection instance | | ||
<a name="OracleDB.extend"></a> | ||
### OracleDB.extend(oracledb) | ||
Extends the provided oracledb instance. | ||
**Kind**: static method of <code>[OracleDB](#OracleDB)</code> | ||
**Access:** public | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| oracledb | <code>object</code> | The oracledb instance | | ||
<a name="Pool"></a> | ||
@@ -941,5 +1060,2 @@ | ||
* ["connection-released" (connection)](#SimpleOracleDB+event_connection-released) | ||
* _static_ | ||
* [.oracle.getConnection(connectionAttributes, [callback])](#SimpleOracleDB.oracle.getConnection) ⇒ <code>Promise</code> | ||
* [.oracle.createPool(poolAttributes, [callback])](#SimpleOracleDB.oracle.createPool) ⇒ <code>Promise</code> | ||
@@ -1099,34 +1215,2 @@ <a name="new_SimpleOracleDB_new"></a> | ||
<a name="SimpleOracleDB.oracle.getConnection"></a> | ||
### SimpleOracleDB.oracle.getConnection(connectionAttributes, [callback]) ⇒ <code>Promise</code> | ||
Wraps the original oracledb getConnection in order to provide an extended connection object. | ||
**Kind**: static method of <code>[SimpleOracleDB](#SimpleOracleDB)</code> | ||
**Returns**: <code>Promise</code> - In case of no callback provided in input, this function will return a promise | ||
**Access:** public | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| connectionAttributes | <code>object</code> | The connection attributes object | | ||
| [callback] | <code>[AsyncCallback](#AsyncCallback)</code> | Invoked with an error or the oracle connection instance | | ||
<a name="SimpleOracleDB.oracle.createPool"></a> | ||
### SimpleOracleDB.oracle.createPool(poolAttributes, [callback]) ⇒ <code>Promise</code> | ||
Wraps the original oracledb createPool in order to provide an extended pool object. | ||
**Kind**: static method of <code>[SimpleOracleDB](#SimpleOracleDB)</code> | ||
**Returns**: <code>Promise</code> - In case of no callback provided in input, this function will return a promise | ||
**Access:** public | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| poolAttributes | <code>object</code> | | The connection pool attributes object (see https://github.com/oracle/node-oracledb/blob/master/doc/api.md#createpool for more attributes) | | ||
| [poolAttributes.retryCount] | <code>number</code> | <code>10</code> | The max amount of retries to get a connection from the pool in case of any error | | ||
| [poolAttributes.retryInterval] | <code>number</code> | <code>250</code> | The interval in millies between get connection retry attempts | | ||
| [poolAttributes.runValidationSQL] | <code>boolean</code> | <code>true</code> | True to ensure the connection returned is valid by running a test validation SQL | | ||
| [poolAttributes.validationSQL] | <code>string</code> | <code>"SELECT 1 FROM DUAL"</code> | The test SQL to invoke before returning a connection to validate the connection is open | | ||
| [callback] | <code>[AsyncCallback](#AsyncCallback)</code> | | Invoked with an error or the oracle connection pool instance | | ||
<a name="ConnectionAction"></a> | ||
@@ -1133,0 +1217,0 @@ |
| Date | Version | Description | | ||
| ----------- | ------- | ----------- | | ||
| 2016-10-04 | v1.1.23 | Maintenance | | ||
| 2016-10-06 | v1.1.24 | Maintenance | | ||
| 2016-08-15 | v1.1.2 | Added 'metadata' event for connection.query with streaming | | ||
@@ -5,0 +5,0 @@ | 2016-08-15 | v1.1.1 | Maintenance | |
@@ -134,3 +134,3 @@ 'use strict'; | ||
}, function attemptGetConnection(asyncCallback) { | ||
self.getConnectionOrg(function onConnection(error, connection) { | ||
self.baseGetConnection(function onConnection(error, connection) { | ||
if (error) { | ||
@@ -338,3 +338,2 @@ debug('Unable to get pooled connection, ', error.stack); | ||
if (pool && (!pool.simplified)) { | ||
pool.getConnectionOrg = pool.getConnection; | ||
pool.poolAttributes = poolAttributes || {}; | ||
@@ -341,0 +340,0 @@ |
@@ -40,9 +40,10 @@ 'use strict'; | ||
var emitter = require('./emitter'); | ||
var OracleDB = require('./oracledb'); | ||
var Pool = require('./pool'); | ||
var Connection = require('./connection'); | ||
var constants = require('./constants'); | ||
var extensions = require('./extensions'); | ||
var Monitor = require('./monitor'); | ||
var promiseHelper = require('./promise-helper'); | ||
var proxyEventsDone = false; | ||
/** | ||
@@ -162,104 +163,20 @@ * Simple oracledb enables to extend the oracledb main object, oracledb pool and oracledb connection.<br> | ||
if (oracle.createPool) { | ||
oracle.simplified = true; | ||
OracleDB.extend(oracle); | ||
//update type meta info | ||
if (oracle.BLOB !== undefined) { | ||
constants.blobType = oracle.BLOB; | ||
} | ||
if (oracle.CLOB !== undefined) { | ||
constants.clobType = oracle.CLOB; | ||
} | ||
if (oracle.BIND_OUT !== undefined) { | ||
constants.bindOut = oracle.BIND_OUT; | ||
} | ||
var getConnectionOrg = oracle.getConnection; | ||
/*eslint-disable valid-jsdoc*/ | ||
//jscs:disable jsDoc | ||
/** | ||
* Wraps the original oracledb getConnection in order to provide an extended connection object. | ||
* | ||
* @function | ||
* @memberof! SimpleOracleDB | ||
* @public | ||
* @param {object} connectionAttributes - The connection attributes object | ||
* @param {AsyncCallback} [callback] - Invoked with an error or the oracle connection instance | ||
* @returns {Promise} In case of no callback provided in input, this function will return a promise | ||
*/ | ||
oracle.getConnection = function () { | ||
var argumentsArray = Array.prototype.slice.call(arguments, 0); | ||
var callback = argumentsArray.pop(); | ||
var wrapperCallback = function onConnection(error, connection) { | ||
/*istanbul ignore else*/ | ||
if ((!error) && connection) { | ||
self.emit('connection-created', connection); | ||
connection.once('release', function onRelease() { | ||
self.emit('connection-released', connection); | ||
}); | ||
} | ||
callback(error, connection); | ||
}; | ||
argumentsArray.push(Connection.wrapOnConnection(wrapperCallback)); | ||
getConnectionOrg.apply(oracle, argumentsArray); | ||
}; | ||
//jscs:enable jsDoc | ||
/*eslint-enable valid-jsdoc*/ | ||
//add promise support | ||
oracle.getConnection = promiseHelper.promisify(oracle.getConnection); | ||
var createPoolOrg = oracle.createPool; | ||
/*eslint-disable valid-jsdoc*/ | ||
//jscs:disable jsDoc | ||
/** | ||
* Wraps the original oracledb createPool in order to provide an extended pool object. | ||
* | ||
* @function | ||
* @memberof! SimpleOracleDB | ||
* @public | ||
* @param {object} poolAttributes - The connection pool attributes object (see https://github.com/oracle/node-oracledb/blob/master/doc/api.md#createpool for more attributes) | ||
* @param {number} [poolAttributes.retryCount=10] - The max amount of retries to get a connection from the pool in case of any error | ||
* @param {number} [poolAttributes.retryInterval=250] - The interval in millies between get connection retry attempts | ||
* @param {boolean} [poolAttributes.runValidationSQL=true] - True to ensure the connection returned is valid by running a test validation SQL | ||
* @param {string} [poolAttributes.validationSQL=SELECT 1 FROM DUAL] - The test SQL to invoke before returning a connection to validate the connection is open | ||
* @param {AsyncCallback} [callback] - Invoked with an error or the oracle connection pool instance | ||
* @returns {Promise} In case of no callback provided in input, this function will return a promise | ||
*/ | ||
oracle.createPool = function () { | ||
var argumentsArray = Array.prototype.slice.call(arguments, 0); | ||
var callback = argumentsArray.pop(); | ||
var poolAttributes; | ||
if (argumentsArray && argumentsArray.length) { | ||
poolAttributes = argumentsArray[0]; | ||
} | ||
argumentsArray.push(function onPool(error, pool) { | ||
if ((!error) && pool) { | ||
Pool.extend(pool, poolAttributes); | ||
self.emit('pool-created', pool); | ||
pool.once('release', function onRelease() { | ||
self.emit('pool-released', pool); | ||
}); | ||
} | ||
callback(error, pool); | ||
if (oracle.simplified && (!proxyEventsDone)) { | ||
[ | ||
'pool-created', | ||
'pool-released', | ||
'connection-created', | ||
'connection-released' | ||
].forEach(function createProxy(event) { | ||
oracle.on(event, function onEvent() { | ||
var eventArguments = Array.prototype.slice.call(arguments, 0); | ||
eventArguments.unshift(event); | ||
self.emit.apply(self, eventArguments); | ||
}); | ||
}); | ||
createPoolOrg.apply(oracle, argumentsArray); | ||
}; | ||
//jscs:enable jsDoc | ||
/*eslint-enable valid-jsdoc*/ | ||
//add promise support | ||
oracle.createPool = promiseHelper.promisify(oracle.createPool); | ||
proxyEventsDone = true; | ||
} | ||
} else if (oracle.getConnection) { | ||
@@ -266,0 +183,0 @@ Pool.extend(oracle); |
{ | ||
"name": "simple-oracledb", | ||
"version": "1.1.23", | ||
"version": "1.1.24", | ||
"description": "Extend capabilities of oracledb with simplified API for quicker development.", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -12,2 +12,6 @@ # {"gitdown": "gitinfo", "name": "name"} | ||
* [OracleDB](#usage-oracledb) | ||
* [Event: pool-created](#event-pool-created-oracledb) | ||
* [Event: pool-released](#event-pool-released-oracledb) | ||
* [Event: connection-created](#event-connection-created-oracledb) | ||
* [Event: connection-released](#event-connection-released-oracledb) | ||
* [createPool](#usage-createpool) | ||
@@ -37,2 +41,3 @@ * [Pool](#usage-pool) | ||
* [Event: pool-created](#event-pool-created-simpleoracledb) | ||
* [Event: pool-released](#event-pool-released-simpleoracledb) | ||
* [Event: connection-created](#event-connection-created-simpleoracledb) | ||
@@ -127,2 +132,30 @@ * [Event: connection-released](#event-connection-released-simpleoracledb) | ||
<a name="event-pool-created-oracledb"></a> | ||
### Event: 'pool-created' | ||
* pool - The pool instance | ||
This events is triggered when a pool is created. | ||
<a name="event-pool-released-oracledb"></a> | ||
### Event: 'pool-released' | ||
* pool - The pool instance | ||
This events is triggered after a pool is released. | ||
<a name="event-connection-created-oracledb"></a> | ||
### Event: 'connection-created' | ||
* connection - The connection instance | ||
This events is triggered when a connection is created via oracledb. | ||
<a name="event-connection-released-oracledb"></a> | ||
### Event: 'connection-released' | ||
* connection - The connection instance | ||
This events is triggered when a connection is released successfully. | ||
<a name="usage-createpool"></a> | ||
@@ -129,0 +162,0 @@ ### 'oracledb.createPool(poolAttributes, [callback]) ⇒ [Promise]' |
@@ -12,2 +12,6 @@ # simple-oracledb | ||
* [OracleDB](#usage-oracledb) | ||
* [Event: pool-created](#event-pool-created-oracledb) | ||
* [Event: pool-released](#event-pool-released-oracledb) | ||
* [Event: connection-created](#event-connection-created-oracledb) | ||
* [Event: connection-released](#event-connection-released-oracledb) | ||
* [createPool](#usage-createpool) | ||
@@ -37,2 +41,3 @@ * [Pool](#usage-pool) | ||
* [Event: pool-created](#event-pool-created-simpleoracledb) | ||
* [Event: pool-released](#event-pool-released-simpleoracledb) | ||
* [Event: connection-created](#event-connection-created-simpleoracledb) | ||
@@ -127,2 +132,30 @@ * [Event: connection-released](#event-connection-released-simpleoracledb) | ||
<a name="event-pool-created-oracledb"></a> | ||
### Event: 'pool-created' | ||
* pool - The pool instance | ||
This events is triggered when a pool is created. | ||
<a name="event-pool-released-oracledb"></a> | ||
### Event: 'pool-released' | ||
* pool - The pool instance | ||
This events is triggered after a pool is released. | ||
<a name="event-connection-created-oracledb"></a> | ||
### Event: 'connection-created' | ||
* connection - The connection instance | ||
This events is triggered when a connection is created via oracledb. | ||
<a name="event-connection-released-oracledb"></a> | ||
### Event: 'connection-released' | ||
* connection - The connection instance | ||
This events is triggered when a connection is released successfully. | ||
<a name="usage-createpool"></a> | ||
@@ -839,3 +872,3 @@ ### 'oracledb.createPool(poolAttributes, [callback]) ⇒ [Promise]' | ||
| ----------- | ------- | ----------- | | ||
| 2016-10-04 | v1.1.23 | Maintenance | | ||
| 2016-10-06 | v1.1.24 | Maintenance | | ||
| 2016-08-15 | v1.1.2 | Added 'metadata' event for connection.query with streaming | | ||
@@ -842,0 +875,0 @@ | 2016-08-15 | v1.1.1 | Maintenance | |
@@ -26,3 +26,3 @@ 'use strict'; | ||
assert.isTrue(testPool.simplified); | ||
assert.isFunction(testPool.getConnectionOrg); | ||
assert.isFunction(testPool.baseGetConnection); | ||
}); | ||
@@ -48,3 +48,3 @@ | ||
assert.isTrue(testPool.simplified); | ||
assert.isFunction(testPool.getConnectionOrg); | ||
assert.isFunction(testPool.baseGetConnection); | ||
assert.isFunction(testPool.testPoolFunc); | ||
@@ -83,3 +83,3 @@ assert.isTrue(testPool.coreFunc()); | ||
assert.isTrue(testPool.simplified); | ||
assert.isFunction(testPool.getConnectionOrg); | ||
assert.isFunction(testPool.baseGetConnection); | ||
assert.isFunction(testPool.testPoolFunc); | ||
@@ -86,0 +86,0 @@ assert.isTrue(testPool.coreFunc()); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
709381
61
15036
936