@edu-tosel/mysql2-handler
TypeScript icon, indicating that this package has built-in type declarations

0.5.7 • Public • Published

mysql2-handler

The custom handler for mysql2 module.

Installation

npm install @edu-tosel/mysql2-handler

Environment Variables

export DB_HOST='localhost'
export DB_USER='root'
export DB_PASSWORD='password'
export DB_NAME='database'
export DB_PORT='3306'
export DATE_STRINGS='DATE' # or 'DATETIME' or 'TIMESTAMP'
# ...export DATE_STRINGS='DATETIME'
export CONNECTION_LIMIT='10'
export CASTED_BOOLEAN='true' # or 'false'

Default configuration

  • DB_HOST: None
  • DB_USER: None
  • DB_PASSWORD: None
  • DB_NAME: None
  • DB_PORT: 3306
  • DATE_STRINGS: 'DATE'
  • CONNECTION_LIMIT: 5
  • TIMEZONE: 'UTC'
  • CASTED_BOOLEAN: false

Usage

const mysqlHandler = require("@edu-tosel/mysql2-handler");
function select1() {
  return mysqlHandler.handler(async (connection) => {
    const [rows, fields] = await connection.execute("SELECT 1 AS `one`");
    return rows; // [{one: 1}]
  });
}
select1().then(console.log).catch(console.error); // stdout: [{one: 1}]

/@edu-tosel/mysql2-handler/

    Package Sidebar

    Install

    npm i @edu-tosel/mysql2-handler

    Weekly Downloads

    10

    Version

    0.5.7

    License

    MIT

    Unpacked Size

    30.3 kB

    Total Files

    13

    Last publish

    Collaborators

    • park_jonghyeok
    • shrobin
    • jaegyeom
    • minhyeong
    • bingha
    • tosel