namshi/node-mysql2-promise

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

mysql-promise

Small promises wrapper for mysql2, it's forked and compatible with mysql-promise.

build status NPM NPM

Installation

This module is installed via npm:

m install mysql2-promise --save
Example Usage of query
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);

Example Usage of execute

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);

Example usage of namedPlaceholders
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);

Credits

This library is forked from mysql-promise


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.