nodejs环境快速操作mysql数据库的方法详解
网络编程 2021-07-04 14:07www.168986.cn编程入门
这篇文章主要介绍了nodejs环境快速操作mysql数据库的方法详解,需要的朋友可以参考下
github地址https://github./dmhsq/dmhsq-mysql-db
可用于腾讯云SCF以及云开发环境
错误处理尚未完善 错误参考mysql错误
引入依赖包 npm install dmhsq-mysql-db
效果如下
简化了mysql的使用
安装依赖
npm install dmhsq-mysql-db
使用示例
快速操作mysql 错误处理尚未完善 部分错误参考mysql错误
引入资源
const database = require("dmhsq-mysql-db")
连接数据库
let db = new database({ host: 'xxx', port: 'xxx', user: 'xxxx', password: 'xxxx', database: "xxxx" })
引用表
let collection = db.table("user")
查询全部
collection.get().then(res => { console.log(res) })
条件查询
collection.where({ username: "dmhsq" }).get().then(res => { console.log(res) })
插入数据
collection.add({ username: "dmhsq", password: "dmhsq", _id: 123176312 }).then(res => { console.log(res) })
更新数据
collection.updata({ password: "zc" }).where({ username: "dmhsq" }).then(res=>{ console.log(res) })
删除数据
collection.del().where({ username: "dmhsq" }).then(res => { console.log(res) })
到此这篇关于nodejs环境快速操作mysql数据库的方法详解的文章就介绍到这了,更多相关nodejs操作mysql数据库内容请搜索狼蚁SEO以前的文章或继续浏览狼蚁网站SEO优化的相关文章希望大家以后多多支持狼蚁SEO!
上一篇:vue实现密码显示隐藏功能的思路详解
下一篇:vue如何调用浏览器分享功能详解
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程