1.2.0 • Published 6 years ago
mothi v1.2.0
Node-Mysql-Wrapper
Adapt the library by following steps :
- Install
dotenv
module 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 newrow
intotable
withdone
as callback.updateQuery(table, row, where, done)
--> Updaterow
usingwhere
clause intable
withdone
as callback.findQuery(table, where, done)
--> Find intable
usingwhere
withdone
as callback.deleteQuery(table, row, done)
--> Deleterow
fromtable
withdone
as callback.fetchTableQuery(table, done)
--> Get all the rows fromtable
with done as callback.customQuery(query, valueArray, done)
--> Execute customizedquery
usingvalueArray
with 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.