code: function getConnection(pool, scope){
      return new Promise(function(resolve, reject){
  
          // try to get a new connection from current pool
          pool.getConnection(function(err, connection){
              // connection available ?
              if (err){
                  reject(err);
                  return;
              }
  
              // API Wrapper
              const api = exposeAPI(connection);
  
              // execute within scope ?
              if (typeof scope === 'function'){
  
                  // execute async scopee
                  scope.apply(api, [api, connection]).then(function(result){
  
                      // close connection
                      connection.release();
  
                      // success
                      resolve(result);
                  }).catch(function(e){
                      // close connection
                      connection.release();
  
                      // reject
                      reject(e);
                  });
  
              }else{
                  // return connection API
                  resolve(api);
              }
          });
      });
  }
docs: promise wrapper