MySQL toolkit base on mysql
package.
- Promisify
query
method ofmysql
- Useing pool by default
- Some common shorthand methodes
find
findOne
findOneById
findOneByQuery
has
insert
insertAndFind
update
updateAndFind
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')