Install Dependencies npm install dmhsq-mysql-db Usage Examples Quick operation mysql error handling is not yet perfect. For some errors, refer to mysql error Introducing resources const database = require("dmhsq-mysql-db") Connecting to a database let db = new database({ host: 'xxx', port: 'xxx', user: 'xxxx', password: 'xxxx', database: "xxxx" }) Reference table let collection = db.table("user") Search all collection.get().then(res => { console.log(res) }) Conditional Query collection.where({ username: "dmhsq" }).get().then(res => { console.log(res) }) Inserting Data collection.add({ username: "dmhsq", password: "dmhsq", _id: 123176312 }).then(res => { console.log(res) }) Update data collection.updata({ password: "zccc" }).where({ username: "dmhsq" }).then(res=>{ console.log(res) }) Deleting Data collection.del().where({ username: "dmhsq" }).then(res => { console.log(res) }) This concludes this article on how to quickly operate the MySQL database in a nodejs environment. For more information about how to operate the MySQL database in a nodejs environment, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Linux kernel device driver proc file system notes
>>: How to enable slow query log in MySQL
MySQL 5.7.20 installation and configuration metho...
It is very easy to delete a table in MySQL, but y...
Starting from this section, we will explain the i...
Configuration Instructions Linux system: CentOS-7...
A situation that often occurs in a project is tha...
1. Make sure the network connection method is bri...
In front-end development, $ is a function in jQue...
Table of contents Abstraction and reuse Serial Se...
Recently, the project uses kubernetes (hereinafte...
Table of contents 1.kvm deployment 1.1 kvm instal...
Zen Coding It is a text editor plugin. In a text ...
This article example shares the specific code of ...
This article introduces the method of implementin...
1. What are custom hooks Logic reuse Simply put, ...
I recently configured a server using Tencent Clou...