@makebestgame/co-mysql

@makebestgame/co-mysql is a [mysql](https://github.com/mysqljs/mysql) wrapper to be used with [visionmedia's co](https://github.com/visionmedia/co) library which has a centralized config.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@makebestgame/co-mysql
Minified + gzip package size for @makebestgame/co-mysql in KB

Readme

@makebestgame/co-redis is a mysql wrapper to be used with visionmedia's co library.

Usage

const mysql_config = {
  "test": {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "",
    "charset": "utf8",
    "debug": false,
    "notoolquery": true,
    "database": "test"
  },
};

const co = require('co');
const wrapper = require('./index');
wrapper.init(mysql_config);

const conn = wrapper.get('test');
co(async function () {
  const insertSql = 'insert into tt set ?';
  const col2 = 100;
  const data = {
    col1: 'this is col1',
    col2,
  };
  let res = await conn.query(insertSql, data);
  console.log('got', res); // logs 1

  const searchSql = 'select col1 from tt where col2 = ?';
  res = await conn.query(searchSql, [col2]);
  console.log('got', res); // logs 1

  const deleteSql = 'delete from tt where col2 = ?';
  res = await conn.query(deleteSql, [col2]);
  console.log('delete res', res);
  return true;
}).then(
  (data) => console.log('end ok', data),
  err => console.log('end error', err),
);

Installation

$ npm install @makebestgame/co-mysql

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.