Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
simple-oracledb
Advanced tools
Extend capabilities of oracledb with simplified API for quicker development.
Extend capabilities of oracledb with simplified API for quicker development.
This library enables to modify the oracledb main object, oracledb pool and oracledb connection of the official oracle node.js driver.
The main goal is to provide an extended oracledb connection which provides more functionality for most use cases.
The new functionality aim is to be simpler and more strait forward to enable quicker development.
In order to use this library, you need to either extend the main oracledb object as follows:
//load the oracledb library
var oracledb = require('oracledb');
//load the simple oracledb
var SimpleOracleDB = require('simple-oracledb');
//modify the original oracledb library
SimpleOracleDB.extend(oracledb);
//from this point connections fetched via oracledb.getConnection(...) or pool.getConnection(...)
//have access to additional functionality.
oracledb.getConnection(function onConnection(error, connection) {
if (error) {
//handle error
} else {
//work with new capabilities or original oracledb capabilities
connection.query(...);
}
}
Another option is to modify your oracledb pool instance (in case the pool was created outside your code and out of your control), as follows:
//load the simple oracledb
var SimpleOracleDB = require('simple-oracledb');
function myFunction(pool) {
//modify the original oracledb pool instance
SimpleOracleDB.extend(pool);
//from this point connections fetched via pool.getConnection(...)
//have access to additional functionality.
pool.getConnection(function onConnection(error, connection) {
if (error) {
//handle error
} else {
//work with new capabilities or original oracledb capabilities
connection.query(...);
}
}
}
One last option is to modify your oracledb connection instance (in case the connection was created outside your code and out of your control), as follows:
//load the simple oracledb
var SimpleOracleDB = require('simple-oracledb');
function doSomething(connection, callback) {
//modify the original oracledb connection instance
SimpleOracleDB.extend(connection);
//from this point the connection has access to additional functionality as well as the original oracledb capabilities.
connection.query(...);
}
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
Provides simpler interface than the original oracledb connection.execute function to enable simple query invocation.
The callback output will be an array of objects, each object holding a property for each field with the actual value.
All LOBs will be read and all rows will be fetched.
This function is not recommended for huge results sets or huge LOB values as it will consume a lot of memory.
The function arguments used to execute the 'query' are exactly as defined in the oracledb connection.execute function.
connection.query('SELECT department_id, department_name FROM departments WHERE manager_id < :id', [110], function onResults(error, results) {
if (error) {
//handle error...
} else {
//print the 4th row DEPARTMENT_ID column value
console.log(results[3].DEPARTMENT_ID);
}
});
Provides simpler interface than the original oracledb connection.execute function to enable simple insert invocation with LOB support.
The callback output will be the same as oracledb conection.execute.
All LOBs will be written to the DB via streams and only after all LOBs are written the callback will be called.
The function arguments used to execute the 'insert' are exactly as defined in the oracledb connection.execute function, however the options are mandatory.
connection.insert('INSERT INTO mylobs (id, clob_column1, blob_column2) VALUES (:id, EMPTY_CLOB(), EMPTY_BLOB())', { //no need to specify the RETURNING clause in the SQL
id: 110,
clobText1: 'some long clob string', //add bind variable with LOB column name and text content (need to map that name in the options)
blobBuffer2: new Buffer('some blob content, can be binary...') //add bind variable with LOB column name and text content (need to map that name in the options)
}, {
lobMetaInfo: { //if LOBs are provided, this data structure must be provided in the options object and the bind variables parameter must be an object (not array)
clob_column1: 'clobText1', //map oracle column name to bind variable name
blob_column2: 'blobBuffer2'
}
}, function onResults(error, output) {
//continue flow...
});
This function modifies the existing connection.release function by enabling the input callback to be an optional parameter.
Since there is no real way to release a connection that fails to be released, all that you can do in the callback is just log the error and continue.
Therefore this function allows you to ignore the need to pass a callback and makes it as an optional parameter.
connection.release(); //no callback needed
//still possible to call with a release callback function
connection.release(function onRelease(error) {
if (error) {
//now what?
}
});
In order to use this library, just run the following npm install command:
npm install --save simple-oracledb
This library doesn't define oracledb as a dependency and therefore it is not installed when installing simple-oracledb.
You should define oracledb in your package.json and install it based on the oracledb installation instructions found at: https://github.com/oracle/node-oracledb/blob/master/INSTALL.md
The simpler API can lead to higher memory consumption and therefore might not be suitable in all cases.
Also, since this is work in progress, only few capabilities currently were added.
However, in the near future more and more functionality will be added.
See full docs at: API Docs
Date | Version | Description |
---|---|---|
2015-10-18 | v0.0.4 | Added connection.insert support |
2015-10-16 | v0.0.3 | Maintenance |
2015-10-15 | v0.0.1 | Initial release. |
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.
FAQs
Extend capabilities of oracledb with simplified API for quicker development.
The npm package simple-oracledb receives a total of 133 weekly downloads. As such, simple-oracledb popularity was classified as not popular.
We found that simple-oracledb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.