Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-oracledb

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-oracledb - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

53

docs/api.md

@@ -50,2 +50,3 @@ ## Classes

* [#noop()](#Connection+noop) ⇒ <code>undefined</code> ℗
* [#execute(sql, [bindParams], [options], callback)](#Connection+execute)
* [#query(sql, [bindParams], [options], callback)](#Connection+query)

@@ -56,2 +57,3 @@ * [#insert(sql, bindParams, options, callback)](#Connection+insert)

* [#release([callback])](#Connection+release)
* [#commit(callback)](#Connection+commit)
* [#rollback([callback])](#Connection+rollback)

@@ -84,2 +86,15 @@ * [#queryJSON(sql, [bindParams], [options], callback)](#Connection+queryJSON)

**Access:** private
<a name="Connection+execute"></a>
### Connection#execute(sql, [bindParams], [options], callback)
Extends the original oracledb connection.execute to provide additional behavior.
**Access:** public
| Param | Type | Description |
| --- | --- | --- |
| sql | <code>string</code> | The SQL to execute |
| [bindParams] | <code>object</code> | Optional bind parameters |
| [options] | <code>object</code> | Optional execute options |
| callback | <code>[AsyncCallback](#AsyncCallback)</code> | Callback function with the execution results |
<a name="Connection+query"></a>

@@ -252,2 +267,12 @@ ### Connection#query(sql, [bindParams], [options], callback)

```
<a name="Connection+commit"></a>
### Connection#commit(callback)
Extends the connection.commit to prevent commit being invoked while in the middle of a transaction.
**Access:** public
| Param | Type | Description |
| --- | --- | --- |
| callback | <code>function</code> | The commit callback function (see oracledb docs) |
<a name="Connection+rollback"></a>

@@ -421,4 +446,5 @@ ### Connection#rollback([callback])

Once the rollback/commit is done, the provided callback will be invoked with the error (if any) and results of all actions.<br>
It is important inside the actions to call any operation (such as update or insert) with an option autoCommit=false or to set the oracledb.autoCommit=false,
otherwise there will be no way to rollback in case of errors.
When calling any connection operation (execute, insert, update, ...) the connection will automatically set the autoCommit=false and will ignore the value provided.<br>
This is done to prevent commits in the middle of the transaction.<br>
In addition, you can not start a transaction while another transaction is in progress.

@@ -436,24 +462,15 @@ **Access:** public

function insertSomeRows(callback) {
connection.insert(...., {
autoCommit: false
//more options....
}, callback);
connection.insert(...., function (error, results) {
//some more inserts....
connection.insert(...., callback);
});
},
function insertSomeMoreRows(callback) {
connection.insert(...., {
autoCommit: false
//more options....
}, callback);
connection.insert(...., callback);
},
function doSomeUpdates(callback) {
connection.update(...., {
autoCommit: false
//more options....
}, callback);
connection.update(...., callback);
},
function runBatchUpdates(callback) {
connection.batchUpdate(...., {
autoCommit: false
//more options....
}, callback);
connection.batchUpdate(...., callback);
}

@@ -460,0 +477,0 @@ ], function onTransactionResults(error, output) {

@@ -45,2 +45,25 @@ 'use strict';

/**
* Extends the original oracledb connection.execute to provide additional behavior.
*
* @function
* @memberof! Connection
* @public
* @param {string} sql - The SQL to execute
* @param {object} [bindParams] - Optional bind parameters
* @param {object} [options] - Optional execute options
* @param {AsyncCallback} callback - Callback function with the execution results
*/
Connection.prototype.execute = function () {
var argumentsArray = Array.prototype.slice.call(arguments, 0);
if (this.inTransaction && (argumentsArray.length >= 3)) {
if (typeof argumentsArray[2] !== 'function') {
argumentsArray[2].autoCommit = false;
}
}
this.baseExecute.apply(this, argumentsArray);
};
/**
* Provides simpler interface than the original oracledb connection.execute function to enable simple query invocation.<br>

@@ -285,2 +308,18 @@ * The callback output will be an array of objects, each object holding a property for each field with the actual value.<br>

/**
* Extends the connection.commit to prevent commit being invoked while in the middle of a transaction.
*
* @function
* @memberof! Connection
* @public
* @param {function} callback - The commit callback function (see oracledb docs)
*/
Connection.prototype.commit = function (callback) {
if (this.inTransaction) {
callback(new Error('Connection is in the middle of a transaction.'));
} else {
this.baseCommit(callback);
}
};
/**
* This function modifies the existing connection.rollback function by enabling the input

@@ -308,5 +347,9 @@ * callback to be an optional parameter.<br>

Connection.prototype.rollback = function (callback) {
callback = callback || this.noop;
if (this.inTransaction) {
callback(new Error('Connection is in the middle of a transaction.'));
} else {
callback = callback || this.noop;
this.baseRollback(callback);
this.baseRollback(callback);
}
};

@@ -499,2 +542,5 @@

options.autoCommit = false;
if (self.inTransaction) {
commit = false;
}

@@ -527,4 +573,5 @@ var operation = 'update';

* Once the rollback/commit is done, the provided callback will be invoked with the error (if any) and results of all actions.<br>
* It is important inside the actions to call any operation (such as update or insert) with an option autoCommit=false or to set the oracledb.autoCommit=false,
* otherwise there will be no way to rollback in case of errors.
* When calling any connection operation (execute, insert, update, ...) the connection will automatically set the autoCommit=false and will ignore the value provided.<br>
* This is done to prevent commits in the middle of the transaction.<br>
* In addition, you can not start a transaction while another transaction is in progress.
*

@@ -540,24 +587,15 @@ * @function

* function insertSomeRows(callback) {
* connection.insert(...., {
* autoCommit: false
* //more options....
* }, callback);
* connection.insert(...., function (error, results) {
* //some more inserts....
* connection.insert(...., callback);
* });
* },
* function insertSomeMoreRows(callback) {
* connection.insert(...., {
* autoCommit: false
* //more options....
* }, callback);
* connection.insert(...., callback);
* },
* function doSomeUpdates(callback) {
* connection.update(...., {
* autoCommit: false
* //more options....
* }, callback);
* connection.update(...., callback);
* },
* function runBatchUpdates(callback) {
* connection.batchUpdate(...., {
* autoCommit: false
* //more options....
* }, callback);
* connection.batchUpdate(...., callback);
* }

@@ -573,10 +611,18 @@ * ], function onTransactionResults(error, output) {

if (actions && callback && (typeof callback === 'function')) {
if (typeof actions === 'function') {
actions = [actions];
if (self.inTransaction) {
callback(new Error('Connection already running a transaction.'));
} else {
self.inTransaction = true;
if (typeof actions === 'function') {
actions = [actions];
}
asyncLib.parallel(actions, function onTransactionEnd(error, results) {
var transactionCallback = self.createCallback(callback, true, results);
self.inTransaction = false;
transactionCallback(error);
});
}
asyncLib.parallel(actions, function onTransactionEnd(error, results) {
var transactionCallback = self.createCallback(callback, true, results);
transactionCallback(error);
});
}

@@ -583,0 +629,0 @@ };

{
"name": "simple-oracledb",
"version": "0.1.5",
"version": "0.1.6",
"description": "Extend capabilities of oracledb with simplified API for quicker development.",

@@ -5,0 +5,0 @@ "author": {

@@ -370,4 +370,5 @@ # simple-oracledb

Once the rollback/commit is done, the provided callback will be invoked with the error (if any) and results of all actions.<br>
It is important inside the actions to call any operation (such as update or insert) with an option autoCommit=false or to set the oracledb.autoCommit=false,
otherwise there will be no way to rollback in case of errors.
When calling any connection operation (execute, insert, update, ...) the connection will automatically set the autoCommit=false and will ignore the value provided.<br>
This is done to prevent commits in the middle of the transaction.<br>
In addition, you can not start a transaction while another transaction is in progress.

@@ -377,24 +378,15 @@ ```js

function insertSomeRows(callback) {
connection.insert(...., {
autoCommit: false
//more options....
}, callback);
connection.insert(...., function (error, results) {
//some more inserts....
connection.insert(...., callback);
});
},
function insertSomeMoreRows(callback) {
connection.insert(...., {
autoCommit: false
//more options....
}, callback);
connection.insert(...., callback);
},
function doSomeUpdates(callback) {
connection.update(...., {
autoCommit: false
//more options....
}, callback);
connection.update(...., callback);
},
function runBatchUpdates(callback) {
connection.batchUpdate(...., {
autoCommit: false
//more options....
}, callback);
connection.batchUpdate(...., callback);
}

@@ -472,2 +464,3 @@ ], function onTransactionResults(error, output) {

| ----------- | ------- | ----------- |
| 2015-12-30 | v0.1.6 | connection.transaction disables commit/rollback while running |
| 2015-12-29 | v0.1.5 | Maintenance |

@@ -474,0 +467,0 @@ | 2015-12-29 | v0.1.4 | Added connection.transaction |

@@ -9,2 +9,4 @@ 'use strict';

describe('Integration Tests', function () {
var self = this;
var oracledb;

@@ -111,2 +113,4 @@ var integrated = true;

self.timeout(5000);
describe('query', function () {

@@ -1044,3 +1048,2 @@ it('error', function (done) {

], {
autoCommit: false,
lobMetaInfo: {

@@ -1067,3 +1070,2 @@ LOB1: 'clob1',

], {
autoCommit: false,
lobMetaInfo: {

@@ -1155,7 +1157,7 @@ LOB1: 'clob1',

], {
autoCommit: false,
lobMetaInfo: {
LOB1: 'clob1',
LOB2: 'blob2'
}
},
autoCommit: true
}, cb);

@@ -1178,3 +1180,2 @@ },

], {
autoCommit: false,
lobMetaInfo: {

@@ -1181,0 +1182,0 @@ LOB1: 'clob1',

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc