easy-mysql-js
You can do database operations easily with this package.
List of Features
- Select (manual query)
- SelectSingle
- SelectMulti
- Insert
- Update
- InsertOrUpdate
- Delete
Download & Installation
$ npm i easy-mysql-js
Environment Variables
To run this project, you will need to add the following environment variables to your .env file
DATABASE_URL
NODE_ENV
Example Usage
Select
const {Select, SelectSingle, SelectMulti} = require('easy-mysql-js')
async function test() {
const select_result = await Select('asd')
console.log(select_result)
const selectSingle_result = await SelectSingle("users",{id:1},{id:true,name:true,email:true})
console.log(selectSingle_result)
const selectMulti_result = await SelectMulti("users",{},{id:true,name:true,email:true})
console.log(selectMulti_result)
}
test()
Insert
const {Insert} = require('easy-mysql-js')
async function test() {
const insert_result = await Insert("users",{name:"name",email:"asd@asd.com",phone:"1234567890"})
console.log(insert_result)
}
test()
Update
const {Update} = require('easy-mysql-js')
async function test() {
const update_result = await Update("users",{email:"asd@asd.com"},{email:"qwe@qwe.com"})
console.log(update_result)
}
test()
InsertOrUpdate
const {InsertOrUpdate} = require('easy-mysql-js')
async function test() {
const insertOrUpdate_result = await InsertOrUpdate("users",{id:1},{phone:"123123"},{name:"name2",email:"qwe@qwe.com",phone:"1234567891"})
console.log(insertOrUpdate_result)
}
test()
Delete
const {Delete} = require('easy-mysql-js')
async function test() {
const delete_result = await Delete("users",{id:1})
console.log(delete_result)
}
test()
Acknowledgements
License
This project is licensed under the MIT License