The most commonly used module I believe is the mysql
I wear 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 BD connection open and has a pool to manage connections as in the example above.
Michael, the answer was right in your question?
– Sergio