/mysql-kit

Primary LanguageTypeScriptApache License 2.0Apache-2.0

MySQL-Kit

npm version build status coverage

MySQL toolkit base on mysql package.

  • Promisify query method of mysql
  • Useing pool by default
  • Some common shorthand methodes
    • find
    • findOne
    • findOneById
    • findOneByQuery
    • has
    • insert
    • insertAndFind
    • update
    • updateAndFind

Usage

Install

# Use yarn
yarn add mysql mysql-kit
yarn add -D @types/mysql

# Use npm
npm install mysql mysql-kit
npm install -D @types/mysql

Use

import mysqlKit from 'mysql-kit'

// Your mysql config
const config = {
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'root',
  database: '__mysql_kit_test__',
}
await mysqlKit.connect(config)

await mysqlKit.query('show tables')