@kevinwang0316/mysql-helper
v1.0.3
Published
A helper to interact with MySQL.
Downloads
3
Maintainers
Readme
MySQLHelper
A helper to manage the connection pool for MySQL.
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.