lib/wrapper.js
function init(input) {
  // Use provided pool
  if(typeof input == 'function') db.pool = input;

  else {
    // Create the pool with any options merged with the below defaults
    db.pool = mysql.createPool(Object.assign({
      user: 'root',
      password: 'root',
      database: 'test'
    },input));
  }

  // Set the local _pool(just for convenience)
  _pool = db.pool;

  return db;
}
function init(input) {
  // Use provided pool
  if(typeof input == 'function') db.pool = input;

  else {
    // Create the pool with any options merged with the below defaults
    db.pool = mysql.createPool(Object.assign({
      user: 'root',
      password: 'root',
      database: 'test'
    },input));
  }

  // Set the local _pool(just for convenience)
  _pool = db.pool;

  return db;
}
function init ( input ) { // Use provided pool if ( typeof input == 'function' ) db . pool = input ; else { // Create the pool with any options merged with the below defaults db . pool = mysql . createPool ( Object . assign ( { user : 'root' , password : 'root' , database : 'test' } , input ) ) ; } // Set the local _pool(just for convenience) _pool = db . pool ; return db ; }
The db function is the initialiser for setting a pool if provided on require
@param {Pool|Object} [input] - Either a mysql.Pool OR a config options object
@return {Function} Returns the db function so we can attach additional exports
The db function is the initialiser for setting a pool if provided on require