3.7.3 • Published 3 months ago

qiao-mysql v3.7.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

qiao-mysql

npm version npm downloads

nodejs 下 mysql 能力

install

安装

npm i qiao-mysql

config

配置文件,如果传入 connectionLimit 会使用 connection pool

{
  "connectionLimit": 10,
  "host": "127.0.0.1",
  "port": 3306,
  "database": "xxx",
  "user": "xxx",
  "password": "xxx"
}

client

// config
const config = require('./config.json');

// client
const client = require('qiao-mysql')(config);

api

getColumns

获取表的列属性

const res = await client.getColumns('t_todo_item');
console.log(res);

getTypes

获取表字段类型对应的 js 类型

const type = client.getTypes('varchar(10)');
console.log(type);

query

查询数据库

|-- 如果配置文件中没有 connectionLimit 属性,则每次创建 connection 后查询

|-- 如果配置文件中有 connectionLimit,则使用 connection pool 查询

const rows = await client.query('select * from t_todo_item where id=?', [8]);
console.log(rows);
3.7.3

3 months ago

3.5.7

7 months ago

3.2.1

10 months ago

3.1.0

11 months ago

3.0.1

1 year ago

3.0.6

12 months ago

1.0.7

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

0.1.7

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago