1.0.2 • Published 2 years ago
mysql-node-ts v1.0.2
安装
npm install mysql-node-ts
引入
import { NodeMysql } from 'mysql-node-ts'
连接数据库
const db = new NodeMysql({
host: '127.0.0.1',
port: 3306,
user: 'root',
password: '123456',
database: 'test'
})
查询
db.table('admins')
.where({ id: 1 })
.where("adminName='admin'")
.orderBy({ id: 'ASC' })
.limit(0, 1)
.find()
.then((res) => console.log(res))
插入
db.table('user')
.create({
username: '尼古拉斯凯奇',
email: 'nglskq@email.com'
})
.then((res) => console.log(res))
修改
db.table('user')
.where({ id: 2 })
.update({ username: 'zs', email: '123@qq.com' })
.then((res) => console.log(res))
删除
db.table('user')
.where('id', 3)
.delete()
.then((res) => console.log(res))
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0-beta2
2 years ago
1.0.0-beta1
2 years ago
1.0.0-beta
2 years ago
1.0.0
2 years ago