Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
npm install yu-mysql
const m = require('yu-mysql')
// 数据库配置
const config = {
host: "your host", //(必选)替换成你的host
user: "root", //(必选)替换成你的user
password: "your password", //(必选)替换成你的password
database: "your database", //(必选)替换成你的database
port: 3306, //(非必选)默认3306
charset: "utf8mb4", //(非必选)默认utf8mb4
timezone: "+08:00" //(非必选)默认+08:00
}
//m.init(config)需在首次调用数据库操作之前调用一次即可
//随后跨模块操作数据库可不再调用本方法
//建议在程序入口模块优先调用一次
m.init(config)
const sqls = [
"select * from table",
"insert into table(name) values('yu')",
"update table set name='yu'",
"delete from table where id=1"
]
//update、insert、delete返回的是rows.affectedRows,select返回的是查询结果数组
//select 的时间数据将被格式化为'YYYY-MM-DD HH:mm:ss'
//返回值示例:retArr=[[{name: 'yu'}, {name: 'yu2'}], 1, 1, 0]
const retArr = await m.transaction(...sqls)
const sql = "select * from table"
//返回值示例:ret=[{name: 'yu',telephone:'12345678910'}, {name: 'yu2',telephone:'12345678910'}]
const ret = await m.select(sql)
//返回值示例:ret=[{name: 'yu'}, {name: 'yu2'}]
const ret = await m.select(sql, ['telephone'])
const datas=[
{name: 'yu', telephone: '12345678910'},
{name: 'yu2', telephone: '12345678910'}
]
//返回值示例:ret=1
const ret = await m.insert('tablename', ...datas)
const datas=[
{id: 1, name: 'yu', telephone: '12345678910'},
{id: 2, name: 'yu2', telephone: '12345678910'}
]
//将id为1的name改为yu,telephone改为12345678910
//将id为2的name改为yu2,telephone改为12345678910
//返回值示例:ret=1
const ret = await m.update('tablename', 'id', ...datas)
//删除id为1的数据
//返回值示例:ret=1
const ret = await m.delete('tablename', `id='1'`)
FAQs
对mysql的进一步封装,减少代码量
We found that yu-mysql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.