simple-oracledb
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -50,2 +50,3 @@ ## Classes | ||
* _static_ | ||
* [.wrapOnConnection(callback)](#Connection.wrapOnConnection) ⇒ <code>function</code> | ||
* [.extend(connection)](#Connection.extend) | ||
@@ -250,2 +251,15 @@ | ||
<a name="Connection.wrapOnConnection"></a> | ||
### Connection.wrapOnConnection(callback) ⇒ <code>function</code> | ||
Returns a getConnection callback wrapper which extends the connection and | ||
calls the original callback. | ||
**Kind**: static method of <code>[Connection](#Connection)</code> | ||
**Returns**: <code>function</code> - The getConnection callback wrapper. | ||
**Access:** public | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| callback | <code>function</code> | The getConnection callback | | ||
<a name="Connection.extend"></a> | ||
@@ -252,0 +266,0 @@ ### Connection.extend(connection) |
@@ -426,2 +426,23 @@ 'use strict'; | ||
/** | ||
* Returns a getConnection callback wrapper which extends the connection and | ||
* calls the original callback. | ||
* | ||
* @function | ||
* @memberof! Connection | ||
* @public | ||
* @param {function} callback - The getConnection callback | ||
* @returns {function} The getConnection callback wrapper. | ||
*/ | ||
wrapOnConnection: function wrapOnConnection(callback) { | ||
var self = this; | ||
return function onConnection(error, connection) { | ||
if ((!error) && connection) { | ||
self.extend(connection); | ||
} | ||
callback(error, connection); | ||
}; | ||
}, | ||
/** | ||
* Extends the provided oracledb connection instance. | ||
@@ -428,0 +449,0 @@ * |
@@ -50,9 +50,3 @@ 'use strict'; | ||
Pool.prototype.getConnection = function (callback) { | ||
this.getConnectionOrg(function onConnection(error, connection) { | ||
if ((!error) && connection) { | ||
Connection.extend(connection); | ||
} | ||
callback(error, connection); | ||
}); | ||
this.getConnectionOrg(Connection.wrapOnConnection(callback)); | ||
}; | ||
@@ -59,0 +53,0 @@ |
@@ -94,10 +94,4 @@ 'use strict'; | ||
var callback = argumentsArray.pop(); | ||
argumentsArray.push(function onConnection(error, connection) { | ||
if ((!error) && connection) { | ||
Connection.extend(connection); | ||
} | ||
argumentsArray.push(Connection.wrapOnConnection(callback)); | ||
callback(error, connection); | ||
}); | ||
return getConnectionOrg.apply(oracle, argumentsArray); | ||
@@ -104,0 +98,0 @@ }; |
{ | ||
"name": "simple-oracledb", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Extend capabilities of oracledb with simplified API for quicker development.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -250,2 +250,3 @@ # simple-oracledb | ||
| ----------- | ------- | ----------- | | ||
| 2015-10-20 | v0.0.11 | Maintenance | | ||
| 2015-10-20 | v0.0.10 | Added connection.queryJSON | | ||
@@ -252,0 +253,0 @@ | 2015-10-19 | v0.0.9 | autoCommit support when doing INSERT/UPDATE with LOBs | |
@@ -604,3 +604,111 @@ 'use strict'; | ||
}); | ||
describe('queryJSON', function () { | ||
it('single row', function (done) { | ||
var table = 'TEST_ORA_JSON1'; | ||
initDB(table, [ | ||
{ | ||
COL1: 'PK1', | ||
COL2: 2, | ||
COL3: 30, | ||
COL4: '123', | ||
LOB1: JSON.stringify({ | ||
json: true, | ||
oracle: true, | ||
text: 'test', | ||
subObj: { | ||
array: [1, 2, 3, '4'] | ||
} | ||
}) | ||
} | ||
], function (pool) { | ||
pool.getConnection(function (err, connection) { | ||
assert.isUndefined(err); | ||
connection.queryJSON('SELECT LOB1 FROM ' + table, function (error, results) { | ||
assert.isNull(error); | ||
assert.equal(results.rowCount, 1); | ||
assert.deepEqual({ | ||
json: true, | ||
oracle: true, | ||
text: 'test', | ||
subObj: { | ||
array: [1, 2, 3, '4'] | ||
} | ||
}, results.json); | ||
end(done, connection); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it('multiple row', function (done) { | ||
var table = 'TEST_ORA_JSON1'; | ||
initDB(table, [ | ||
{ | ||
COL1: 'PK1', | ||
COL2: 2, | ||
COL3: 30, | ||
COL4: '123', | ||
LOB1: JSON.stringify({ | ||
json: true, | ||
oracle: true, | ||
text: 'test', | ||
subObj: { | ||
array: [1, 2, 3, '4'] | ||
} | ||
}) | ||
}, | ||
{ | ||
COL1: 'PK2', | ||
COL2: 2, | ||
COL3: 30, | ||
COL4: '123', | ||
LOB1: JSON.stringify({ | ||
json: 100, | ||
oracle: 'oracledb', | ||
text: 'test', | ||
subObj: { | ||
array: [1, 2, 3, '4', { | ||
works: 'yes' | ||
}] | ||
} | ||
}) | ||
} | ||
], function (pool) { | ||
pool.getConnection(function (err, connection) { | ||
assert.isUndefined(err); | ||
connection.queryJSON('SELECT LOB1 FROM ' + table, function (error, results) { | ||
assert.isNull(error); | ||
assert.equal(results.rowCount, 2); | ||
assert.deepEqual([ | ||
{ | ||
json: true, | ||
oracle: true, | ||
text: 'test', | ||
subObj: { | ||
array: [1, 2, 3, '4'] | ||
} | ||
}, | ||
{ | ||
json: 100, | ||
oracle: 'oracledb', | ||
text: 'test', | ||
subObj: { | ||
array: [1, 2, 3, '4', { | ||
works: 'yes' | ||
}] | ||
} | ||
} | ||
], results.json); | ||
end(done, connection); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); |
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
237237
34
4969
263