mysql-promise

Small wrapper for mysql that use promises.

npm install mysql-promise
3 downloads in the last day
14 downloads in the last week
32 downloads in the last month

mysql-promise

Small wrapper for mysql that use promises.

build status

Installation

This module is installed via npm:

$ npm install mysql-promise

Example Usage

var db = require('mysql-promise')();

db.configure({
    "host": "localhost",
    "user": "foo",
    "password": "bar",
    "database": "db"
});

db.query('UPDATE foo SET key = ?', ['value']).then(function () {
    return db.query('SELECT * FROM foo');
}).spread(function (rows) {
    console.log('Loook at all the foo', rows);
});

//using multiple databases, giving it a name 'second-db' so it can be retrieved inside other modules/files.
var db2 = require('mysql-promise')('second-db');

db2.configure({
    "host": "localhost",
    "user": "foo",
    "password": "bar",
    "database": "another-db"
});

db2.query('SELECT * FROM users').spread(function (users) {
    console.log('Hello users', users);
});
npm loves you