The most used module I believe to be mysql
I use it like this:
var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit: 100,
host: 'localhost',
user: 'root',
password: 'root',
database: 'nomedaBD',
debug: false,
charset: 'utf8_unicode_ci'
});
function query (query, data, callback) {
if (typeof data == 'function') {
callback = data;
data = [];
}
pool.getConnection(function (err, connection) {
if (err) return onError(connection, err, callback);
connection.query(query, data || [], function (err, rows, fields) {
if (err) return onError(connection, err, callback);
connection.release();
callback.call(this, null, rows, fields);
});
});
}
The plugin
keeps the connection to the open DB and has a pool to manage connections as in the example above.