Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mouday/pure-mysql
pure-mysql is node.js module for mysql of simple CURD
https://github.com/mouday/pure-mysql
Last synced: 7 days ago
JSON representation
pure-mysql is node.js module for mysql of simple CURD
- Host: GitHub
- URL: https://github.com/mouday/pure-mysql
- Owner: mouday
- Created: 2020-04-05T16:56:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-16T09:49:15.000Z (3 months ago)
- Last Synced: 2024-09-17T23:08:19.683Z (16 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PureMysql
this is a pure mysql lib, you just can use it to test and a script
use demo
```jsconst config = {
host: 'localhost',
user: 'root',
password: '123456',
port: '3306',
database: 'data',
// debug: ['ComQueryPacket', 'RowDataPacket']
}const con = new Mysql(config)
con.select("select * from students where id = 100")
.then((rows) => {
console.log(ret);
for (const row of ret) {
console.log(row);
}
})con.select("select * from students where name=:name", { name: '李白' })
.then((ret) => {
for (const row of ret) {
console.log(row.name);
}
})con.select("select * from students where name = ?", ['李白'])
.then((ret) => {
for (const row of ret) {
console.log(row);
}
})con.selectOne("select * from students where name = ? limit 1", ['李白'])
.then((ret) => {
console.log(ret);
})con.update("update students set age = :age where id = :id", { age: 30, id: 3 })
.then((ret) => {
console.log(ret);
})con.insert("insert into students (name, age) values(:name, :age)", { age: 30, name: '杰克' })
.then((ret) => {
console.log(ret);
})con.delete("delete from students where id = ?", [5])
.then((ret) => {
console.log(ret);
})con.close()
```