1.2.0 • Published 8 years ago
mothi v1.2.0
Node-Mysql-Wrapper
Adapt the library by following steps :
- Install
dotenvmodule and create .env file in root level of the project. - Configure following variables :
- TTDB_MODE --> dev/prod
- TTDB_HOST_DEV --> development host database IP
- TTDB_USER_DEV --> user name of development database
- TTDB_PW_DEV --> password of development environment
- TTDB_DEV --> development database name
- TTDB_HOST_PROD --> production host database IP
- TTDB_USER_PROD --> user name of production database
- TTDB_PW_PROD --> password of production environment
- TTDB_PROD --> production database name
- TT_PORT --> port number
- Import the module using
var mothi = require('mothi') - Use following APIs to operate on MySQL database.
insertQuery(table, row, done)--> Insert newrowintotablewithdoneas callback.updateQuery(table, row, where, done)--> Updaterowusingwhereclause intablewithdoneas callback.findQuery(table, where, done)--> Find intableusingwherewithdoneas callback.deleteQuery(table, row, done)--> Deleterowfromtablewithdoneas callback.fetchTableQuery(table, done)--> Get all the rows fromtablewith done as callback.customQuery(query, valueArray, done)--> Execute customizedqueryusingvalueArraywith done as callback.
To run test follow below steps :
- Install Mysql software
- Create a database with name 'test' (CLI : mysql -u {username} -p and provide {passeword} and then call "create database test")
- Create a table name 'test'.
This should be sufficient to run test suite.