npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

hapi-mysql

1.0.16

@seldo

npmHomeRepoSnykSocket
Downloads:11
$ npm install hapi-mysql
DailyWeeklyMonthlyYearly

hapi-mysql

Usage

Register plugin:

var server = Hapi.createServer('0.0.0.0', 8000);
server.pack.require('hapi-mysql', Config.db, function(err) {
  if (err) {
    console.error(err);
    throw err;
  }
});

Use plugin:

request.server.plugins['hapi-mysql'].pool.getConnection(function(err, connection) {

  // Use the connection
  connection.query(
    'SELECT 1 FROM mytable',
    function(err, rows) {

      if(err) {
        throw new Error(err)
      }
    }
  )

  // And done with the connection.
  connection.release();
})