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
One trick for dealing with this type of error is t...
In web development, you often encounter characters...
Table of contents 1. Introduction 2. JDBC impleme...
1. Environmental Description (1) CentOS-7-x86_64,...
Tomcat server is a free and open source Web appli...
Disable SeLinux setenforce 0 Permanently closed: ...
Designers need to understand psychology reading n...
1. Source of the problem A friend @水米田 asked me a...
Table of contents 1. Brief Introduction 2. Run sc...
useState useState adds some internal state to a c...
Table of contents 1. Enter a directory and create...
When a web project gets bigger and bigger, its CS...
Table of contents Preface 1. What variables are p...
Performance For example: HTML: <div class=&quo...
You can use yum to install all dependencies toget...