I have mysql connection code which I need to call each time in every .js file. Say I want sql.js
from main.js
. I am thinking include(sql.js)
?
sql.js
var sql = require('sql');
var connection = sql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'db'
});
connection.connect(function(err){
if(!err) {
console.log("connected");
}