yn-mysql-utils
v1.0.4
Published
A secondary package plugin for mysql database operations
Downloads
4
Readme
yn-mysql-utils
The simple secondary packaging of the mysql database plug-in is easy to use in the project, improve project development efficiency and reduce development costs!
Install
npm install yn-mysql-utils --save
Or
cnpm install yn-mysql-utils --save
Usage
const mysql = require('yn-mysql-utils')
Example
// Incoming configuration, same as mysql
let data = new mysql({
host : '127.0.0.1',
user : 'root',
password : 'lb714500',
database : 'SmallActivity',
connectionLimit : 10
})
/**
* Start query
* sql: Query sql statement, string type
* par: Query parameter, array type
*/
data.Query({
sql: 'select * from activity_page where id = ?',
par: [ 2 ]
}).then(res => {
// Get the query result
console.log(res)
/* Data example
[ RowDataPacket {
id: 2,
page_title: '红包拿不停',
page_starttime: '2018-10-28 18:45:14',
page_endtime: '2018-10-31 18:45:14',
page_limit: '200' }
]
*/
})
other methods
You can also use await
or async
in your project.