orawrap
orawrap copied to clipboard
Support for multiple connections?
Is there a way to use orawrap to manage multiple connections? I have many different data sources and need to create a pool for each in the main js file which bootstraps the application, then in the controller files I need to have access to those connections to execute queries.
I no longer recommend using Orawrap. For now, you'll need to create your own wrapper to cache/retrieve pools. Here's an example:
var oracledb = require('oracledb');
var poolMap = {};
function createPool(poolName, config, callback) {
oracledb.createPool(
config,
function(err, p) {
if (err) throw err;
poolMap[poolName] = p;
callback();
}
);
}
module.exports.createPool = createPool;
function getPool(poolName) {
return poolMap[poolName];
}
module.exports.getPool = getPool;
You could save that to a file and then require it in where it's needed.