orawrap icon indicating copy to clipboard operation
orawrap copied to clipboard

Support for multiple connections?

Open sbehun opened this issue 10 years ago • 1 comments

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.

sbehun avatar Apr 29 '16 17:04 sbehun

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.

dmcghan avatar Apr 29 '16 17:04 dmcghan