0.0.4 • Published 1 year ago

@empjourney/mysql-util v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

@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
0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.1-alpha.0

1 year ago