node.js - How to share a common MySQL pool across node modules? -


i have task need make multiple queries (> 10) based on outcome of previous tasks. created connection pool using node-mysql module.

var pool  = mysql.createpool({         connectionlimit: 10,         host     : config.mysql.host,         user     : config.mysql.user,         password : config.mysql.password,         database : config.mysql.database     });  pool.getconnection(function(err, connection) {         //execute task1 -> task2 -> task3,4,5 , on     }) 

now pool created in base module. base module further uses 5-6 other modules handle sub tasks. each of these modules need make queries db. wondering if should pass 'pool' variable each module , connection pool each query. or should connection pool in base module , pass same connection around. or if there better way share common mysql connection pool across modules in nodejs?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -