Name: node-mysql2-promise
Owner: Namshi
Description: null
Created: 2015-04-29 06:13:46.0
Updated: 2016-07-14 07:03:10.0
Pushed: 2017-04-12 06:04:26.0
Homepage: null
Size: 10
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Small promises wrapper for mysql2
,
it's forked and compatible with mysql-promise
.
This module is installed via npm:
m install mysql2-promise --save
db = require('mysql2-promise')();
onfigure({
"host": "localhost",
"user": "foo",
"password": "bar",
"database": "db"
uery('UPDATE foo SET key = ?', ['value']).then(function () {
return db.query('SELECT * FROM foo');
pread(function (rows) {
console.log('Look at all the foo', rows);
ing multiple databases, giving it a name 'second-db' so it can be retrieved inside other modules/files.
db2 = require('mysql-promise')('second-db');
configure({
"host": "localhost",
"user": "foo",
"password": "bar",
"database": "another-db"
query('SELECT * FROM users').spread(function (users) {
console.log('Hello users', users);
execute()
function is similar to query
but it use prepared-statements.
db = require('mysql2-promise')();
onfigure({
"host": "localhost",
"user": "foo",
"password": "bar",
"database": "db"
xecute('SELECT * FROM users WHERE LIMIT = ?', [10]).spread(function (users) {
console.log('Hello users', users);
db = require('mysql2-promise')();
onfigure({
"host": "localhost",
"user": "foo",
"password": "bar",
"database": "db"
ool.on('connection', function (poolConnection) {
poolConnection.config.namedPlaceholders = true;
xecute('SELECT * FROM users WHERE LIMIT = :limit', {limit: 10}).spread(function (users) {
console.log('Hello users', users);
This library is forked from mysql-promise