simple-oracledb
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -229,3 +229,5 @@ ## Classes | ||
* [.simplified](#Pool.simplified) : <code>boolean</code> | ||
* [#noop()](#Pool+noop) ⇒ <code>undefined</code> ℗ | ||
* [#getConnection(callback)](#Pool+getConnection) | ||
* [#terminate([callback])](#Pool+terminate) | ||
* _static_ | ||
@@ -243,2 +245,8 @@ * [.extend(pool)](#Pool.extend) | ||
**Access:** public | ||
<a name="Pool+noop"></a> | ||
### Pool#noop() ⇒ <code>undefined</code> ℗ | ||
Empty function. | ||
**Returns**: <code>undefined</code> - Empty return | ||
**Access:** private | ||
<a name="Pool+getConnection"></a> | ||
@@ -255,2 +263,27 @@ ### Pool#getConnection(callback) | ||
<a name="Pool+terminate"></a> | ||
### Pool#terminate([callback]) | ||
This function modifies the existing pool.terminate function by enabling the input | ||
callback to be an optional parameter.<br> | ||
Since there is no real way to release the pool that fails to be terminated, all that you can do in the callback | ||
is just log the error and continue.<br> | ||
Therefore this function allows you to ignore the need to pass a callback and makes it as an optional parameter. | ||
**Access:** public | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [callback] | <code>function</code> | An optional terminate callback function (see oracledb docs) | | ||
**Example** | ||
```js | ||
pool.terminate(); //no callback needed | ||
//still possible to call with a terminate callback function | ||
pool.terminate(function onTerminate(error) { | ||
if (error) { | ||
//now what? | ||
} | ||
}); | ||
``` | ||
<a name="Pool.extend"></a> | ||
@@ -257,0 +290,0 @@ ### Pool.extend(pool) |
@@ -29,2 +29,14 @@ 'use strict'; | ||
/** | ||
* Empty function. | ||
* | ||
* @function | ||
* @memberof! Pool | ||
* @private | ||
* @returns {undefined} Empty return | ||
*/ | ||
Pool.prototype.noop = function () { | ||
return undefined; | ||
}; | ||
/** | ||
* Wraps the original oracledb getConnection in order to provide an extended connection object.<br> | ||
@@ -48,2 +60,31 @@ * See https://github.com/oracle/node-oracledb/blob/master/doc/api.md#getconnectionpool for more details. | ||
/** | ||
* This function modifies the existing pool.terminate function by enabling the input | ||
* callback to be an optional parameter.<br> | ||
* Since there is no real way to release the pool that fails to be terminated, all that you can do in the callback | ||
* is just log the error and continue.<br> | ||
* Therefore this function allows you to ignore the need to pass a callback and makes it as an optional parameter. | ||
* | ||
* @function | ||
* @memberof! Pool | ||
* @public | ||
* @param {function} [callback] - An optional terminate callback function (see oracledb docs) | ||
* @example | ||
* ```js | ||
* pool.terminate(); //no callback needed | ||
* | ||
* //still possible to call with a terminate callback function | ||
* pool.terminate(function onTerminate(error) { | ||
* if (error) { | ||
* //now what? | ||
* } | ||
* }); | ||
* ``` | ||
*/ | ||
Pool.prototype.terminate = function (callback) { | ||
callback = callback || this.noop; | ||
this.baseTerminate(callback); | ||
}; | ||
module.exports = { | ||
@@ -65,2 +106,6 @@ /** | ||
properties.forEach(function addProperty(property) { | ||
if (pool[property]) { | ||
pool['base' + property.charAt(0).toUpperCase() + property.slice(1)] = pool[property]; | ||
} | ||
pool[property] = Pool.prototype[property]; | ||
@@ -67,0 +112,0 @@ }); |
{ | ||
"name": "simple-oracledb", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Extend capabilities of oracledb with simplified API for quicker development.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,3 @@ # simple-oracledb | ||
* [release](#usage-release) | ||
* [terminate](#usage-terminate) | ||
* [Installation](#installation) | ||
@@ -174,2 +175,21 @@ * [Limitations](#limitations) | ||
``` | ||
<a name="usage-terminate"></a> | ||
## 'pool.terminate([callback])' | ||
This function modifies the existing pool.terminate function by enabling the input | ||
callback to be an optional parameter.<br> | ||
Since there is no real way to release the pool that fails to be terminated, all that you can do in the callback | ||
is just log the error and continue.<br> | ||
Therefore this function allows you to ignore the need to pass a callback and makes it as an optional parameter. | ||
```js | ||
pool.terminate(); //no callback needed | ||
//still possible to call with a terminate callback function | ||
pool.terminate(function onTerminate(error) { | ||
if (error) { | ||
//now what? | ||
} | ||
}); | ||
``` | ||
<br> | ||
@@ -204,2 +224,3 @@ **The rest of the API is the same as defined in the oracledb library: https://github.com/oracle/node-oracledb/blob/master/doc/api.md** | ||
| ----------- | ------- | ----------- | | ||
| 2015-10-19 | v0.0.7 | Added pool.terminate support | | ||
| 2015-10-19 | v0.0.6 | Maintenance | | ||
@@ -206,0 +227,0 @@ | 2015-10-18 | v0.0.5 | Added connection.update support | |
@@ -46,2 +46,36 @@ 'use strict'; | ||
}); | ||
describe('terminate', function () { | ||
it('callback provided', function (done) { | ||
var pool = { | ||
terminate: function (cb) { | ||
assert.isFunction(cb); | ||
cb(); | ||
done(); | ||
} | ||
}; | ||
Pool.extend(pool); | ||
assert.isFunction(pool.baseTerminate); | ||
pool.terminate(function () { | ||
return undefined; | ||
}); | ||
}); | ||
it('callback undefined', function (done) { | ||
var pool = { | ||
terminate: function (cb) { | ||
assert.isFunction(cb); | ||
cb(); | ||
done(); | ||
} | ||
}; | ||
Pool.extend(pool); | ||
assert.isFunction(pool.baseTerminate); | ||
pool.terminate(); | ||
}); | ||
}); | ||
}); |
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
205414
4252
232