simple-oracledb
Advanced tools
Comparing version 0.0.29 to 0.0.30
118
docs/api.md
## Classes | ||
<dl> | ||
@@ -20,3 +21,5 @@ <dt><a href="#Connection">Connection</a></dt> | ||
</dl> | ||
## Objects | ||
<dl> | ||
@@ -27,3 +30,5 @@ <dt><a href="#Constants">Constants</a> : <code>object</code></dt> | ||
</dl> | ||
## Typedefs | ||
<dl> | ||
@@ -34,2 +39,3 @@ <dt><a href="#AsyncCallback">AsyncCallback</a> : <code>function</code></dt> | ||
</dl> | ||
<a name="Connection"></a> | ||
@@ -42,17 +48,18 @@ ## Connection | ||
* [Connection](#Connection) | ||
* [new Connection()](#new_Connection_new) | ||
* [.simplified](#Connection.simplified) : <code>boolean</code> | ||
* [#noop()](#Connection+noop) ⇒ <code>undefined</code> ℗ | ||
* [#query(sql, [bindParams], [options], callback)](#Connection+query) | ||
* [#insert(sql, bindParams, options, callback)](#Connection+insert) | ||
* [#update(sql, bindParams, options, callback)](#Connection+update) | ||
* [#release([callback])](#Connection+release) | ||
* [#rollback([callback])](#Connection+rollback) | ||
* [#queryJSON(sql, [bindParams], [options], callback)](#Connection+queryJSON) | ||
* [#batchInsert(sql, bindParamsArray, options, callback)](#Connection+batchInsert) | ||
* [#modifyParams(argumentsArray)](#Connection+modifyParams) ⇒ <code>object</code> ℗ | ||
* [#createCallback(callback, commit, [output])](#Connection+createCallback) ⇒ <code>function</code> ℗ | ||
* _static_ | ||
* [.wrapOnConnection(callback)](#Connection.wrapOnConnection) ⇒ <code>function</code> | ||
* [.extend(connection)](#Connection.extend) | ||
* [new Connection()](#new_Connection_new) | ||
* [.simplified](#Connection.simplified) : <code>boolean</code> | ||
* [#noop()](#Connection+noop) ⇒ <code>undefined</code> ℗ | ||
* [#query(sql, [bindParams], [options], callback)](#Connection+query) | ||
* [#insert(sql, bindParams, options, callback)](#Connection+insert) | ||
* [#update(sql, bindParams, options, callback)](#Connection+update) | ||
* [#insertOrUpdate(insert, argumentsArray)](#Connection+insertOrUpdate) ℗ | ||
* [#release([callback])](#Connection+release) | ||
* [#rollback([callback])](#Connection+rollback) | ||
* [#queryJSON(sql, [bindParams], [options], callback)](#Connection+queryJSON) | ||
* [#batchInsert(sql, bindParamsArray, options, callback)](#Connection+batchInsert) | ||
* [#modifyParams(argumentsArray)](#Connection+modifyParams) ⇒ <code>object</code> ℗ | ||
* [#createCallback(callback, commit, [output])](#Connection+createCallback) ⇒ <code>function</code> ℗ | ||
* _static_ | ||
* [.wrapOnConnection(callback)](#Connection.wrapOnConnection) ⇒ <code>function</code> | ||
* [.extend(connection)](#Connection.extend) | ||
@@ -171,2 +178,13 @@ <a name="new_Connection_new"></a> | ||
``` | ||
<a name="Connection+insertOrUpdate"></a> | ||
### Connection#insertOrUpdate(insert, argumentsArray) ℗ | ||
Internal function which handles both INSERT and UPDATE commands. | ||
**Access:** private | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| insert | <code>boolean</code> | True for insert, false for update | | ||
| argumentsArray | <code>Array</code> | The original arguments array | | ||
<a name="Connection+release"></a> | ||
@@ -355,9 +373,9 @@ ### Connection#release([callback]) | ||
* [Pool](#Pool) | ||
* [new Pool()](#new_Pool_new) | ||
* [.simplified](#Pool.simplified) : <code>boolean</code> | ||
* [#noop()](#Pool+noop) ⇒ <code>undefined</code> ℗ | ||
* [#getConnection(callback)](#Pool+getConnection) | ||
* [#terminate([callback])](#Pool+terminate) | ||
* _static_ | ||
* [.extend(pool, [poolAttributes])](#Pool.extend) | ||
* [new Pool()](#new_Pool_new) | ||
* [.simplified](#Pool.simplified) : <code>boolean</code> | ||
* [#noop()](#Pool+noop) ⇒ <code>undefined</code> ℗ | ||
* [#getConnection(callback)](#Pool+getConnection) | ||
* [#terminate([callback])](#Pool+terminate) | ||
* _static_ | ||
* [.extend(pool, [poolAttributes])](#Pool.extend) | ||
@@ -441,7 +459,7 @@ <a name="new_Pool_new"></a> | ||
* [RecordReader](#RecordReader) | ||
* [new RecordReader()](#new_RecordReader_new) | ||
* [#getValue(field, callback)](#RecordReader+getValue) ℗ | ||
* [#createFieldHandler(jsObject, columnName, value)](#RecordReader+createFieldHandler) ⇒ <code>function</code> ℗ | ||
* [#read(columnNames, row, callback)](#RecordReader+read) | ||
* [#readJSON(jsRow, column)](#RecordReader+readJSON) ⇒ <code>object</code> | ||
* [new RecordReader()](#new_RecordReader_new) | ||
* [#getValue(field, callback)](#RecordReader+getValue) ℗ | ||
* [#createFieldHandler(jsObject, columnName, value)](#RecordReader+createFieldHandler) ⇒ <code>function</code> ℗ | ||
* [#read(columnNames, row, callback)](#RecordReader+read) | ||
* [#readJSON(jsRow, column)](#RecordReader+readJSON) ⇒ <code>object</code> | ||
@@ -507,5 +525,5 @@ <a name="new_RecordReader_new"></a> | ||
* [RecordWriter](#RecordWriter) | ||
* [new RecordWriter()](#new_RecordWriter_new) | ||
* [#write(outBindings, lobData, callback)](#RecordWriter+write) | ||
* [#writeMultiple(outBindings, lobData, callback)](#RecordWriter+writeMultiple) | ||
* [new RecordWriter()](#new_RecordWriter_new) | ||
* [#write(outBindings, lobData, callback)](#RecordWriter+write) | ||
* [#writeMultiple(outBindings, lobData, callback)](#RecordWriter+writeMultiple) | ||
@@ -547,6 +565,6 @@ <a name="new_RecordWriter_new"></a> | ||
* [ResultSetReader](#ResultSetReader) | ||
* [new ResultSetReader()](#new_ResultSetReader_new) | ||
* [#readNextRows(columnNames, resultSet, callback)](#ResultSetReader+readNextRows) ℗ | ||
* [#readAllRows(columnNames, resultSet, callback, jsRowsBuffer)](#ResultSetReader+readAllRows) ℗ | ||
* [#read(columnNames, resultSet, callback)](#ResultSetReader+read) | ||
* [new ResultSetReader()](#new_ResultSetReader_new) | ||
* [#readNextRows(columnNames, resultSet, callback)](#ResultSetReader+readNextRows) ℗ | ||
* [#readAllRows(columnNames, resultSet, callback, jsRowsBuffer)](#ResultSetReader+readAllRows) ℗ | ||
* [#read(columnNames, resultSet, callback)](#ResultSetReader+read) | ||
@@ -601,5 +619,5 @@ <a name="new_ResultSetReader_new"></a> | ||
* [RowsReader](#RowsReader) | ||
* [new RowsReader()](#new_RowsReader_new) | ||
* [#read(columnNames, rows, callback)](#RowsReader+read) | ||
* [#readJSON(jsRows)](#RowsReader+readJSON) ⇒ <code>object</code> | ||
* [new RowsReader()](#new_RowsReader_new) | ||
* [#read(columnNames, rows, callback)](#RowsReader+read) | ||
* [#readJSON(jsRows)](#RowsReader+readJSON) ⇒ <code>object</code> | ||
@@ -640,9 +658,9 @@ <a name="new_RowsReader_new"></a> | ||
* [SimpleOracleDB](#SimpleOracleDB) | ||
* [new SimpleOracleDB()](#new_SimpleOracleDB_new) | ||
* [#extend(oracledb)](#SimpleOracleDB+extend) | ||
* [#extend(pool)](#SimpleOracleDB+extend) | ||
* [#extend(connection)](#SimpleOracleDB+extend) | ||
* _static_ | ||
* [.oracle.getConnection(connectionAttributes, callback)](#SimpleOracleDB.oracle.getConnection) | ||
* [.oracle.createPool(poolAttributes, callback)](#SimpleOracleDB.oracle.createPool) | ||
* [new SimpleOracleDB()](#new_SimpleOracleDB_new) | ||
* [#extend(oracledb)](#SimpleOracleDB+extend) | ||
* [#extend(pool)](#SimpleOracleDB+extend) | ||
* [#extend(connection)](#SimpleOracleDB+extend) | ||
* _static_ | ||
* [.oracle.getConnection(connectionAttributes, callback)](#SimpleOracleDB.oracle.getConnection) | ||
* [.oracle.createPool(poolAttributes, callback)](#SimpleOracleDB.oracle.createPool) | ||
@@ -722,5 +740,5 @@ <a name="new_SimpleOracleDB_new"></a> | ||
* [Stream](#Stream) | ||
* [new Stream()](#new_Stream_new) | ||
* [#read(readableStream, binary, callback)](#Stream+read) | ||
* [#write(writableStream, data, callback)](#Stream+write) | ||
* [new Stream()](#new_Stream_new) | ||
* [#read(readableStream, binary, callback)](#Stream+read) | ||
* [#write(writableStream, data, callback)](#Stream+write) | ||
@@ -763,5 +781,5 @@ <a name="new_Stream_new"></a> | ||
* [Constants](#Constants) : <code>object</code> | ||
* [.clobType](#Constants.clobType) : <code>number</code> | ||
* [.blobType](#Constants.blobType) : <code>number</code> | ||
* [.bindOut](#Constants.bindOut) : <code>number</code> | ||
* [.clobType](#Constants.clobType) : <code>number</code> | ||
* [.blobType](#Constants.blobType) : <code>number</code> | ||
* [.bindOut](#Constants.bindOut) : <code>number</code> | ||
@@ -768,0 +786,0 @@ <a name="Constants.clobType"></a> |
220
Gruntfile.js
@@ -7,220 +7,16 @@ 'use strict'; | ||
grunt.config.init({ | ||
var options = { | ||
BuildConfig: { | ||
libDirectory: 'lib', | ||
testDirectory: 'test', | ||
targetDirectory: 'target' | ||
targetDirectory: 'target', | ||
buildDirectory: 'build' | ||
}, | ||
clean: { | ||
options: { | ||
force: true | ||
}, | ||
dot: 'true', | ||
target: { | ||
src: [ | ||
'<%=BuildConfig.targetDirectory%>/**' | ||
] | ||
} | ||
}, | ||
jsonlint: { | ||
full: { | ||
src: [ | ||
'<%=BuildConfig.libDirectory%>/**/*.json', | ||
'*.json' | ||
] | ||
} | ||
}, | ||
jshint: { | ||
full: { | ||
files: { | ||
src: [ | ||
'*.js', | ||
'<%=BuildConfig.libDirectory%>/**/*.js' | ||
] | ||
} | ||
}, | ||
options: { | ||
jshintrc: true | ||
} | ||
}, | ||
jslint: { | ||
full: { | ||
src: [ | ||
'*.js', | ||
'<%=BuildConfig.libDirectory%>/**/*.js' | ||
], | ||
options: { | ||
edition: 'latest', | ||
failOnError: true | ||
}, | ||
directives: grunt.file.readJSON('.jslintrc') | ||
} | ||
}, | ||
eslint: { | ||
full: { | ||
options: { | ||
config: '.eslintrc.json' | ||
}, | ||
src: [ | ||
'*.js', | ||
'<%=BuildConfig.libDirectory%>/**/*.js' | ||
] | ||
} | ||
}, | ||
jscs: { | ||
full: { | ||
options: { | ||
config: '.jscs.json' | ||
}, | ||
files: { | ||
src: [ | ||
'*.js', | ||
'<%=BuildConfig.libDirectory%>/**/*.js' | ||
] | ||
} | ||
} | ||
}, | ||
todos: { | ||
options: { | ||
priorities: { | ||
high: /(todo|TODO|fixme|FIXME)/ | ||
} | ||
}, | ||
full: { | ||
src: [ | ||
'index.js', | ||
'<%=BuildConfig.libDirectory%>/**/*.js', | ||
'<%=BuildConfig.testDirectory%>/**/*.js' | ||
] | ||
} | ||
}, | ||
copy: { | ||
coverage: { | ||
files: [ | ||
{ | ||
expand: true, | ||
src: ['index.js'], | ||
dest: '<%=BuildConfig.targetDirectory%>/coverage' | ||
}, | ||
{ | ||
expand: true, | ||
src: ['<%=BuildConfig.testDirectory%>/spec/**'], | ||
dest: '<%=BuildConfig.targetDirectory%>/coverage' | ||
}, | ||
{ | ||
expand: true, | ||
src: ['<%=BuildConfig.testDirectory%>/helpers/**/*'], | ||
dest: '<%=BuildConfig.targetDirectory%>/coverage' | ||
} | ||
] | ||
} | ||
}, | ||
blanket: { | ||
full: { | ||
files: { | ||
'target/coverage/lib': ['<%=BuildConfig.libDirectory%>/'] | ||
} | ||
} | ||
}, | ||
mochaTest: { | ||
full: { | ||
options: { | ||
reporter: 'spec' | ||
}, | ||
src: ['./<%=BuildConfig.testDirectory%>/**/*spec.js'] | ||
}, | ||
coverageLCOV: { | ||
options: { | ||
require: 'blanket', | ||
reporter: 'mocha-lcov-reporter', | ||
quiet: true, | ||
captureFile: '<%=BuildConfig.targetDirectory%>/coverage/report/coverage.info' | ||
}, | ||
src: ['./<%=BuildConfig.targetDirectory%>/coverage/test/**/*spec.js'] | ||
}, | ||
coverageHTML: { | ||
options: { | ||
reporter: 'html-cov', | ||
quiet: true, | ||
captureFile: '<%=BuildConfig.targetDirectory%>/coverage/report/coverage.html' | ||
}, | ||
src: ['./<%=BuildConfig.targetDirectory%>/coverage/test/**/*spec.js'] | ||
} | ||
}, | ||
coveralls: { | ||
options: { | ||
force: true | ||
}, | ||
full: { | ||
src: '<%=BuildConfig.targetDirectory%>/coverage/report/*.info' | ||
} | ||
}, | ||
jsdoc2md: { | ||
api: { | ||
options: { | ||
index: true, | ||
private: true | ||
}, | ||
src: '<%=BuildConfig.libDirectory%>/**/*.js', | ||
dest: 'docs/api.md' | ||
} | ||
config: { | ||
src: 'build/*.js' | ||
} | ||
}); | ||
}; | ||
grunt.registerTask('cleanup', 'Cleanups', [ | ||
'clean:target' | ||
]); | ||
grunt.registerTask('lint', 'Linting tasks.', [ | ||
'jsonlint:full', | ||
'jshint:full', | ||
'jslint:full', | ||
'eslint:full', | ||
'jscs:full', | ||
'todos:full' | ||
]); | ||
grunt.registerTask('coverage-prepare', 'Pre test tasks', [ | ||
'cleanup', | ||
'copy:coverage', | ||
'blanket:full' | ||
]); | ||
grunt.registerTask('test', 'Continues integration related tasks.', [ | ||
'lint', | ||
'coverage-ci' | ||
]); | ||
grunt.registerTask('docs', 'Generate docs.', [ | ||
'jsdoc2md:api' | ||
]); | ||
grunt.registerTask('coverage-ci', 'Test for continues integration.', [ | ||
'coverage-prepare', | ||
'mochaTest:coverageLCOV', | ||
'coveralls:full' | ||
]); | ||
grunt.registerTask('coverage-html', 'Test for standalone builds.', [ | ||
'coverage-prepare', | ||
'mochaTest:coverageHTML' | ||
]); | ||
grunt.registerTask('build', 'Run all build steps.', [ | ||
'lint', | ||
'docs', | ||
'coverage-html' | ||
]); | ||
var configs = require('load-grunt-configs')(grunt, options); | ||
grunt.initConfig(configs); | ||
}; |
@@ -122,25 +122,4 @@ 'use strict'; | ||
Connection.prototype.insert = function () { | ||
var self = this; | ||
var argumentsArray = Array.prototype.slice.call(arguments, 0); | ||
var lobInfo = this.modifyParams(argumentsArray); | ||
var lobColumns = lobInfo.lobColumns; | ||
var lobData = lobInfo.lobData; | ||
var autoCommit = lobInfo.autoCommit; | ||
var callback = argumentsArray.pop(); | ||
argumentsArray.push(function onExecute(error, results) { | ||
var wrapper = self.createCallback(callback, autoCommit, results); | ||
if (error || (!results)) { | ||
wrapper(error); | ||
} else if ((results.rowsAffected === 1) && lobColumns && lobColumns.length) { | ||
recordWriter.write(results.outBinds, lobData, wrapper); | ||
} else { | ||
wrapper(error); | ||
} | ||
}); | ||
self.execute.apply(self, argumentsArray); | ||
this.insertOrUpdate(true, argumentsArray); | ||
}; | ||
@@ -182,7 +161,19 @@ | ||
Connection.prototype.update = function () { | ||
var argumentsArray = Array.prototype.slice.call(arguments, 0); | ||
this.insertOrUpdate(false, argumentsArray); | ||
}; | ||
/** | ||
* Internal function which handles both INSERT and UPDATE commands. | ||
* | ||
* @function | ||
* @memberof! Connection | ||
* @private | ||
* @param {boolean} insert - True for insert, false for update | ||
* @param {Array} argumentsArray - The original arguments array | ||
*/ | ||
Connection.prototype.insertOrUpdate = function (insert, argumentsArray) { | ||
var self = this; | ||
var argumentsArray = Array.prototype.slice.call(arguments, 0); | ||
var lobInfo = this.modifyParams(argumentsArray); | ||
var lobInfo = self.modifyParams(argumentsArray); | ||
var lobColumns = lobInfo.lobColumns; | ||
@@ -196,9 +187,13 @@ var lobData = lobInfo.lobData; | ||
if (error || (!results)) { | ||
wrapper(error); | ||
} else if ((results.rowsAffected >= 1) && lobColumns && lobColumns.length) { | ||
recordWriter.writeMultiple(results.outBinds, lobData, wrapper); | ||
} else { | ||
wrapper(error); | ||
if ((!error) && results && lobColumns && lobColumns.length) { | ||
if (insert && (results.rowsAffected === 1)) { | ||
recordWriter.write(results.outBinds, lobData, wrapper); | ||
wrapper = self.noop; | ||
} else if ((!insert) && (results.rowsAffected >= 1)) { | ||
recordWriter.writeMultiple(results.outBinds, lobData, wrapper); | ||
wrapper = self.noop; | ||
} | ||
} | ||
wrapper(error, results); | ||
}); | ||
@@ -501,21 +496,26 @@ | ||
var invoked = false; | ||
return function onCallback(error) { | ||
if (error) { | ||
if (commit) { | ||
self.rollback(function onRollback() { | ||
if (!invoked) { | ||
invoked = true; | ||
if (error) { | ||
if (commit) { | ||
self.rollback(function onRollback() { | ||
callback(error); | ||
}); | ||
} else { | ||
callback(error); | ||
} | ||
} else if (commit) { | ||
self.commit(function onCommit(commitError) { | ||
if (commitError) { | ||
callback(commitError); | ||
} else { | ||
callback(null, output); | ||
} | ||
}); | ||
} else { | ||
callback(error); | ||
callback(null, output); | ||
} | ||
} else if (commit) { | ||
self.commit(function onCommit(commitError) { | ||
if (commitError) { | ||
callback(commitError); | ||
} else { | ||
callback(null, output); | ||
} | ||
}); | ||
} else { | ||
callback(null, output); | ||
} | ||
@@ -522,0 +522,0 @@ }; |
{ | ||
"name": "simple-oracledb", | ||
"version": "0.0.29", | ||
"version": "0.0.30", | ||
"description": "Extend capabilities of oracledb with simplified API for quicker development.", | ||
@@ -57,2 +57,3 @@ "author": { | ||
"husky": "latest", | ||
"load-grunt-configs": "latest", | ||
"load-grunt-tasks": "latest", | ||
@@ -59,0 +60,0 @@ "mocha": "latest", |
@@ -59,3 +59,3 @@ # simple-oracledb | ||
} | ||
} | ||
}); | ||
``` | ||
@@ -83,3 +83,3 @@ | ||
} | ||
} | ||
}); | ||
} | ||
@@ -351,3 +351,3 @@ ``` | ||
| ----------- | ------- | ----------- | | ||
| 2015-12-12 | v0.0.29 | Maintenance | | ||
| 2015-12-13 | v0.0.30 | Maintenance | | ||
| 2015-12-08 | v0.0.24 | Added pool.getConnection connection validation via running SQL test command | | ||
@@ -354,0 +354,0 @@ | 2015-11-30 | v0.0.23 | Maintenance | |
Sorry, the diff of this file is not supported yet
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
284987
52
6065
22