@kevinwang0316/mysql-helper

1.0.3 • Public • Published

MySQLHelper

A helper to manage the connection pool for MySQL.

Build Status Coverage Status

Installing

npm install --save @kevinwang0316/mysql-helper

Usage

// Node
const { initialPool, query, getPool, release } = require('@kevinwang0316/redis-helper');
// ES6
//import {
//  initialPool, query, getPool, release,
//} from '@kevinwang0316/redis-helper';

// Initialize the client before you use other functions (the default connectionLimit is 1 for the Lambda function)
initialPool('host', 'user', 'password', 'database');

// Set values
await setAsync('key', 'value');

// Query
query(sql, paramters, callback);
// Or use the async api
const { rows, fields } = await queryAsync(sql, paramters);

// Get MySQL pool if need
const pool = getPool();

// Release the pool if need (If you are using it in a Lambda function, do not release the pool in ordor to reuse)
release();

License

RedisHelper is licensed under MIT License - see the License file.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    3
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    3
  • 1.0.2
    1
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i @kevinwang0316/mysql-helper

Weekly Downloads

6

Version

1.0.3

License

MIT

Unpacked Size

5.98 kB

Total Files

4

Last publish

Collaborators

  • kevinwang0316