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
Table of contents Configuration command steps in ...
export default ({ url, method = 'GET', da...
Scenario: When starting tomcat in docker (version...
Omit the protocol of the resource file It is reco...
<br />This article will briefly introduce yo...
#docker ps check, all ports are mapped CONTAINER ...
Sometimes you just want to test an app but don’t ...
Background: Linux server file upload and download...
This article describes the MySQL multi-table join...
Table of contents Modify the repository source st...
Knowledge point 1: Set the base URL of the web pa...
I recently encountered a problem when doing IM, a...
Generally, lists have selection functions, and si...
Connections can be used to query, update, and est...
Table of contents 1. DOM Diff 2. Add key attribut...