github地址https://github.com/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: "zccc" }).where({ username: "dmhsq" }).then(res=>{ console.log(res) })
删除数据
collection.del().where({ username: "dmhsq" }).then(res => { console.log(res) })
到此这篇关于nodejs环境快速操作mysql数据库的方法详解的文章就介绍到这了,更多相关nodejs操作mysql数据库内容请搜索站长技术以前的文章或继续浏览下面的相关文章希望大家以后多多支持站长技术!
边框: Style=border-style:solid;border-width:5px;border-color:颜色 透明度:...
一、setup函数的特性以及作用 可以确定的是 Vue3.0 是兼容 Vue2.x 版本的 也就是...
卷标 , 属性名称 , 简介 002 ! - - ... - - 批注 003 ! 跑马灯 004 marquee.../m...
我就废话不多说了,大家还是直接看代码吧` let label(){let _this = this;let _o...
文章目录 1. 简述 2. 使用说明 3. 效果展示 3.1 左下角展示内容 3.2 清屏效果 3....
Taglib指令介绍 Taglib指令,其实就是定义一个标签库以及自定义标签的前缀。 比...
Linux export命令会标记哪些值需要传递给一组子进程。这是bash shell提供的一个...
一、Redis在微博的应用场景 Redis在微博内部分布在各个应用场景,比如像现在春晚...
一、正则表达式去除代码行号 作为开发人员,我们经常从网上复制一些代码,有些时...
这款经典的文本编辑器提供了所有的基本功能和一些让你自定义你的体验的令人兴奋...