@empjourney/mysql-util
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@empjourney/mysql

This library is a mysql2 wrapper with intuitive developer friendly methods

Usage

import mysqlUtil  from '@empjourney/mysql-util';

Once imported, get the singleton instance

 const dbInstance = await MySqlUtil.getInstance({
      host: process.env.MYSQL_HOST,
      user: process.env.MYSQL_USER,
      password: process.env.MYSQL_PASSWORD,
      database: process.env.MYSQL_DATABASE //optional
    });
})

This gives you instance of MySqlUtil which has following methods:

Method (all async) Description
query (dbName:string) runs query against DbPool
createAndUseDatabase (dbName:string) Creates database and switches to it
useDatabase (dbName:string) switches to it
dropDatabase (dbName:string) Drops the database
createTable(tableName: string,columns: TableColumn) Creates table with specified column details
generateInsertStatements(tableName: string) Generated Insert Queries for all rows
describeTable(tableName: string) Returns all columns with description

Readme

Keywords

Package Sidebar

Install

npm i @empjourney/mysql-util

Weekly Downloads

0

Version

0.0.2

License

ISC

Unpacked Size

10.9 kB

Total Files

7

Last publish

Collaborators

  • deepakaggarwal