Skip to content

Commit eb9f391

Browse files
authored
feat: support mysql2 (#1)
- support mysql2 - rename to myrds Co-authored-by: raoha.rh <raohai.rh@antgroup.com>
1 parent 70869e2 commit eb9f391

File tree

16 files changed

+134
-112
lines changed

16 files changed

+134
-112
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ jobs:
1414
with:
1515
os: 'ubuntu-latest'
1616
version: '16.17.0, 16, 18, 20'
17+
mysql_version: '5, 8'

CHANGELOG.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# Changelog
22

3-
## [6.3.0](https://github.com/ali-sdk/ali-rds/compare/v6.2.0...v6.3.0) (2023-07-31)
3+
## [6.3.0](https://github.com/node-modules/myrds/v6.2.0...v6.3.0) (2023-07-31)
44

55

66
### Features
77

8-
* stats 增加使用中的连接数 ([#115](https://github.com/ali-sdk/ali-rds/issues/115)) ([2b152a1](https://github.com/ali-sdk/ali-rds/commit/2b152a14b39291665c74910f2fe803d8318843db))
8+
* stats 增加使用中的连接数 ([#115](https://github.com/node-modules/myrds/issues/115)) ([2b152a1](https://github.com/node-modules/myrds/commit/2b152a14b39291665c74910f2fe803d8318843db))
99

10-
## [6.2.0](https://github.com/ali-sdk/ali-rds/compare/v6.1.0...v6.2.0) (2023-06-10)
10+
## [6.2.0](https://github.com/node-modules/myrds/v6.1.0...v6.2.0) (2023-06-10)
1111

1212

1313
### Features
1414

15-
* export connection and query diagnostics_channel ([#111](https://github.com/ali-sdk/ali-rds/issues/111)) ([64aa75d](https://github.com/ali-sdk/ali-rds/commit/64aa75d121d63ddae4fa4bd2a6e097773f280dfe))
15+
* export connection and query diagnostics_channel ([#111](https://github.com/node-modules/myrds/issues/111)) ([64aa75d](https://github.com/node-modules/myrds/commit/64aa75d121d63ddae4fa4bd2a6e097773f280dfe))
1616

17-
## [6.1.0](https://github.com/ali-sdk/ali-rds/compare/v6.0.1...v6.1.0) (2023-06-09)
17+
## [6.1.0](https://github.com/node-modules/myrds/v6.0.1...v6.1.0) (2023-06-09)
1818

1919

2020
### Features
2121

22-
* dynamic retrieval of database connection configuration ([#110](https://github.com/ali-sdk/ali-rds/issues/110)) ([f437efb](https://github.com/ali-sdk/ali-rds/commit/f437efb439c1770561c1d4dc79318c632e7321d9))
22+
* dynamic retrieval of database connection configuration ([#110](https://github.com/node-modules/myrds/issues/110)) ([f437efb](https://github.com/node-modules/myrds/commit/f437efb439c1770561c1d4dc79318c632e7321d9))
2323

24-
## [6.0.1](https://github.com/ali-sdk/ali-rds/compare/v6.0.0...v6.0.1) (2023-06-05)
24+
## [6.0.1](https://github.com/node-modules/myrds/v6.0.0...v6.0.1) (2023-06-05)
2525

2626

2727
### Bug Fixes
2828

29-
* mysql type not found ([#109](https://github.com/ali-sdk/ali-rds/issues/109)) ([6a9bc45](https://github.com/ali-sdk/ali-rds/commit/6a9bc452a8a73f9d697ee0e55f91b823ef153df4))
29+
* mysql type not found ([#109](https://github.com/node-modules/myrds/issues/109)) ([6a9bc45](https://github.com/node-modules/myrds/commit/6a9bc452a8a73f9d697ee0e55f91b823ef153df4))
3030

31-
## [6.0.0](https://github.com/ali-sdk/ali-rds/compare/v5.1.2...v6.0.0) (2023-06-03)
31+
## [6.0.0](https://github.com/node-modules/myrds/v5.1.2...v6.0.0) (2023-06-03)
3232

3333

3434
### ⚠ BREAKING CHANGES
@@ -37,35 +37,35 @@
3737

3838
### Features
3939

40-
* use AsyncLocalStorage to refactor transaction, to make it more safe ([#108](https://github.com/ali-sdk/ali-rds/issues/108)) ([ae327fa](https://github.com/ali-sdk/ali-rds/commit/ae327fa5a350b48c4e1f56c2769524c5786e1152))
40+
* use AsyncLocalStorage to refactor transaction, to make it more safe ([#108](https://github.com/node-modules/myrds/issues/108)) ([ae327fa](https://github.com/node-modules/myrds/commit/ae327fa5a350b48c4e1f56c2769524c5786e1152))
4141

4242

4343
### Bug Fixes
4444

45-
* use master branch ([758877d](https://github.com/ali-sdk/ali-rds/commit/758877d9e01df74b9df12c65b7f625275996656b))
45+
* use master branch ([758877d](https://github.com/node-modules/myrds/commit/758877d9e01df74b9df12c65b7f625275996656b))
4646

47-
## [5.1.2](https://github.com/ali-sdk/ali-rds/compare/v5.1.1...v5.1.2) (2023-03-06)
47+
## [5.1.2](https://github.com/node-modules/myrds/v5.1.1...v5.1.2) (2023-03-06)
4848

4949

5050
### Bug Fixes
5151

52-
* don't export protected methods ([#106](https://github.com/ali-sdk/ali-rds/issues/106)) ([b2757df](https://github.com/ali-sdk/ali-rds/commit/b2757dffdf76bb74e9fff8a89632d19704b03e4f))
52+
* don't export protected methods ([#106](https://github.com/node-modules/myrds/issues/106)) ([b2757df](https://github.com/node-modules/myrds/commit/b2757dffdf76bb74e9fff8a89632d19704b03e4f))
5353

54-
## [5.1.1](https://github.com/ali-sdk/ali-rds/compare/v5.1.0...v5.1.1) (2023-03-05)
54+
## [5.1.1](https://github.com/node-modules/myrds/v5.1.0...v5.1.1) (2023-03-05)
5555

5656

5757
### Bug Fixes
5858

59-
* support multi lifecircle hooks ([#105](https://github.com/ali-sdk/ali-rds/issues/105)) ([53b0a70](https://github.com/ali-sdk/ali-rds/commit/53b0a7058e4f3e583dc4610b1d1338014b9f2c15))
59+
* support multi lifecircle hooks ([#105](https://github.com/node-modules/myrds/issues/105)) ([53b0a70](https://github.com/node-modules/myrds/commit/53b0a7058e4f3e583dc4610b1d1338014b9f2c15))
6060

61-
## [5.1.0](https://github.com/ali-sdk/ali-rds/compare/v5.0.0...v5.1.0) (2023-03-05)
61+
## [5.1.0](https://github.com/node-modules/myrds/v5.0.0...v5.1.0) (2023-03-05)
6262

6363

6464
### Features
6565

66-
* support custom query lifecircle ([#104](https://github.com/ali-sdk/ali-rds/issues/104)) ([5941c69](https://github.com/ali-sdk/ali-rds/commit/5941c69b461ad581aa88c211ee6c60a88d4f5420))
66+
* support custom query lifecircle ([#104](https://github.com/node-modules/myrds/issues/104)) ([5941c69](https://github.com/node-modules/myrds/commit/5941c69b461ad581aa88c211ee6c60a88d4f5420))
6767

68-
## [5.0.0](https://github.com/ali-sdk/ali-rds/compare/v4.1.0...v5.0.0) (2023-03-04)
68+
## [5.0.0](https://github.com/node-modules/myrds/v4.1.0...v5.0.0) (2023-03-04)
6969

7070

7171
### ⚠ BREAKING CHANGES
@@ -74,100 +74,100 @@
7474

7575
### Features
7676

77-
* impl with typescript ([#103](https://github.com/ali-sdk/ali-rds/issues/103)) ([1cf7814](https://github.com/ali-sdk/ali-rds/commit/1cf7814effb2876919e73d331547ecd14caf45f4))
77+
* impl with typescript ([#103](https://github.com/node-modules/myrds/issues/103)) ([1cf7814](https://github.com/node-modules/myrds/commit/1cf7814effb2876919e73d331547ecd14caf45f4))
7878

79-
## [4.1.0](https://github.com/ali-sdk/ali-rds/compare/v4.0.3...v4.1.0) (2023-01-01)
79+
## [4.1.0](https://github.com/node-modules/myrds/v4.0.3...v4.1.0) (2023-01-01)
8080

8181

8282
### Features
8383

84-
* add unlock/lock tables ([#97](https://github.com/ali-sdk/ali-rds/issues/97)) ([4dc3452](https://github.com/ali-sdk/ali-rds/commit/4dc3452a375e0c242084e23c6e5f1cb76f1b647d))
85-
* add unlock/lock tables ([#97](https://github.com/ali-sdk/ali-rds/issues/97)) ([0a61be6](https://github.com/ali-sdk/ali-rds/commit/0a61be6048db4df298bfff33c6d23bdcc0119b9a))
84+
* add unlock/lock tables ([#97](https://github.com/node-modules/myrds/issues/97)) ([4dc3452](https://github.com/node-modules/myrds/commit/4dc3452a375e0c242084e23c6e5f1cb76f1b647d))
85+
* add unlock/lock tables ([#97](https://github.com/node-modules/myrds/issues/97)) ([0a61be6](https://github.com/node-modules/myrds/commit/0a61be6048db4df298bfff33c6d23bdcc0119b9a))
8686

87-
## [4.0.3](https://github.com/ali-sdk/ali-rds/compare/v4.0.2...v4.0.3) (2022-12-22)
87+
## [4.0.3](https://github.com/node-modules/myrds/v4.0.2...v4.0.3) (2022-12-22)
8888

8989

9090
### Bug Fixes
9191

92-
* export pool getter from rds client ([#102](https://github.com/ali-sdk/ali-rds/issues/102)) ([4048807](https://github.com/ali-sdk/ali-rds/commit/40488070b8bbae853a75ebe7d82a6cff6c8d071d))
92+
* export pool getter from rds client ([#102](https://github.com/node-modules/myrds/issues/102)) ([4048807](https://github.com/node-modules/myrds/commit/40488070b8bbae853a75ebe7d82a6cff6c8d071d))
9393

94-
## [4.0.2](https://github.com/ali-sdk/ali-rds/compare/v4.0.1...v4.0.2) (2022-12-22)
94+
## [4.0.2](https://github.com/node-modules/myrds/v4.0.1...v4.0.2) (2022-12-22)
9595

9696

9797
### Bug Fixes
9898

99-
* should export conn property ([#101](https://github.com/ali-sdk/ali-rds/issues/101)) ([37afa42](https://github.com/ali-sdk/ali-rds/commit/37afa420f3330cbc7a5e6e68da88086339a2a955))
99+
* should export conn property ([#101](https://github.com/node-modules/myrds/issues/101)) ([37afa42](https://github.com/node-modules/myrds/commit/37afa420f3330cbc7a5e6e68da88086339a2a955))
100100

101101
---
102102

103103
4.0.1 / 2022-12-14
104104
==================
105105

106106
**fixes**
107-
* [[`add4669`](https://github.com/ali-sdk/ali-rds/commit/add466917422b15deddd434c25595b6f6082bb6b)] - 🐛 FIX: Export db pool stats (#95) (fengmk2 <<fengmk2@gmail.com>>)
107+
* [[`add4669`](https://github.com/node-modules/myrds/commit/add466917422b15deddd434c25595b6f6082bb6b)] - 🐛 FIX: Export db pool stats (#95) (fengmk2 <<fengmk2@gmail.com>>)
108108

109109
4.0.0 / 2022-12-14
110110
==================
111111

112112
**features**
113-
* [[`6296b5b`](https://github.com/ali-sdk/ali-rds/commit/6296b5b1a0e08bf88097937a0b579a4c90b13a2d)] - 📦 NEW: [BREAKING] Refactor impl base on async/await (#94) (fengmk2 <<fengmk2@gmail.com>>)
113+
* [[`6296b5b`](https://github.com/node-modules/myrds/commit/6296b5b1a0e08bf88097937a0b579a4c90b13a2d)] - 📦 NEW: [BREAKING] Refactor impl base on async/await (#94) (fengmk2 <<fengmk2@gmail.com>>)
114114

115115
3.4.1 / 2022-12-13
116116
==================
117117

118118
**fixes**
119-
* [[`d983478`](https://github.com/ali-sdk/ali-rds/commit/d983478d40203357c71187c94f44ef3afab0b604)] - fix: handle concurrent transaction (#85) (killa <<killa123@126.com>>)
119+
* [[`d983478`](https://github.com/node-modules/myrds/commit/d983478d40203357c71187c94f44ef3afab0b604)] - fix: handle concurrent transaction (#85) (killa <<killa123@126.com>>)
120120

121121
**others**
122-
* [[`61e8e38`](https://github.com/ali-sdk/ali-rds/commit/61e8e38208acf4a9cc1780128063318f7f0e17ac)] - Create codeql.yml (fengmk2 <<fengmk2@gmail.com>>)
122+
* [[`61e8e38`](https://github.com/node-modules/myrds/commit/61e8e38208acf4a9cc1780128063318f7f0e17ac)] - Create codeql.yml (fengmk2 <<fengmk2@gmail.com>>)
123123

124124
3.4.0 / 2020-07-16
125125
==================
126126

127127
**features**
128-
* [[`2e99ab8`](https://github.com/ali-sdk/ali-rds/commit/2e99ab8ce872b8482fe2b0a29af51a7a99aaff84)] - feat: export sqlstring method (#79) (Haoliang Gao <<sakura9515@gmail.com>>)
128+
* [[`2e99ab8`](https://github.com/node-modules/myrds/commit/2e99ab8ce872b8482fe2b0a29af51a7a99aaff84)] - feat: export sqlstring method (#79) (Haoliang Gao <<sakura9515@gmail.com>>)
129129

130130
3.3.1 / 2019-04-24
131131
==================
132132

133133
**fixes**
134-
* [[`52147de`](git@github.com:ali-sdk/ali-rds/commit/52147de9d7405b02efcf84ef28a11a4097675972)] - fix: query parameters are not allowed to be included in where (#67) (Hoyt <<hoythan@gmail.com>>)
134+
* [[`52147de`](git@github.com:node-modules/myrds/commit/52147de9d7405b02efcf84ef28a11a4097675972)] - fix: query parameters are not allowed to be included in where (#67) (Hoyt <<hoythan@gmail.com>>)
135135

136136
**others**
137-
* [[`0f9f23b`](git@github.com:ali-sdk/ali-rds/commit/0f9f23bbd935650a1440537b18aaa982a6db2d44)] - chore: remove node 4 in ci (dead-horse <<dead_horse@qq.com>>)
137+
* [[`0f9f23b`](git@github.com:node-modules/myrds/commit/0f9f23bbd935650a1440537b18aaa982a6db2d44)] - chore: remove node 4 in ci (dead-horse <<dead_horse@qq.com>>)
138138

139139
3.3.0 / 2018-12-11
140140
==================
141141

142142
**features**
143-
* [[`0d4d4ab`](https://github.com/ali-sdk/ali-rds/commit/0d4d4ab99a7cd655180f22d4d95e3cfef8c8714b)] - feat: where condition support NULL value (#60) (fengmk2 <<fengmk2@gmail.com>>)
143+
* [[`0d4d4ab`](https://github.com/node-modules/myrds/commit/0d4d4ab99a7cd655180f22d4d95e3cfef8c8714b)] - feat: where condition support NULL value (#60) (fengmk2 <<fengmk2@gmail.com>>)
144144

145145
3.2.0 / 2018-11-19
146146
==================
147147

148148
**features**
149-
* [[`b227bc1`](https://github.com/ali-sdk/ali-rds/commit/b227bc12e5c6252264d4761b72f915b73d53c688)] - feat: support doomed transaction scope on test cases (#58) (AngrySean <<xujihui1985@gmail.com>>)
149+
* [[`b227bc1`](https://github.com/node-modules/myrds/commit/b227bc12e5c6252264d4761b72f915b73d53c688)] - feat: support doomed transaction scope on test cases (#58) (AngrySean <<xujihui1985@gmail.com>>)
150150

151151
3.1.0 / 2018-09-30
152152
==================
153153

154154
**features**
155-
* [[`859d818`](https://github.com/ali-sdk/ali-rds/commit/859d818d7e327d1ff590d363dfbf3135d8c90454)] - feat: update multiple rows (#55) (Hang Jiang <<jianghangscu@gmail.com>>)
155+
* [[`859d818`](https://github.com/node-modules/myrds/commit/859d818d7e327d1ff590d363dfbf3135d8c90454)] - feat: update multiple rows (#55) (Hang Jiang <<jianghangscu@gmail.com>>)
156156

157157
**fixes**
158-
* [[`db6d596`](https://github.com/ali-sdk/ali-rds/commit/db6d59616f4b5083142bed554fb104c1b5a7c14e)] - fix: add default value now() of `gmt_modified` and `gmt_create` (#56) (Hang Jiang <<jianghangscu@gmail.com>>)
158+
* [[`db6d596`](https://github.com/node-modules/myrds/commit/db6d59616f4b5083142bed554fb104c1b5a7c14e)] - fix: add default value now() of `gmt_modified` and `gmt_create` (#56) (Hang Jiang <<jianghangscu@gmail.com>>)
159159

160160
**others**
161-
* [[`db3524c`](https://github.com/ali-sdk/ali-rds/commit/db3524c8da7f8b32291695a2fc5497ea8fddd155)] - doc: add object arguments in readme (#52) (凯 方 <<fkvsssl@126.com>>)
161+
* [[`db3524c`](https://github.com/node-modules/myrds/commit/db3524c8da7f8b32291695a2fc5497ea8fddd155)] - doc: add object arguments in readme (#52) (凯 方 <<fkvsssl@126.com>>)
162162

163163
3.0.1 / 2017-09-26
164164
==================
165165

166166
**fixes**
167-
* [[`5ca4489`](https://github.com/ali-sdk/ali-rds/commit/5ca4489b903923302c81a8c9c8ac94c0afbce819)] - fix: don't redefined sqlstring.escape (#39) (Yiyu He <<dead_horse@qq.com>>)
167+
* [[`5ca4489`](https://github.com/node-modules/myrds/commit/5ca4489b903923302c81a8c9c8ac94c0afbce819)] - fix: don't redefined sqlstring.escape (#39) (Yiyu He <<dead_horse@qq.com>>)
168168

169169
**others**
170-
* [[`004713c`](https://github.com/ali-sdk/ali-rds/commit/004713cf9a4aa2da84a9f02348996b1a8ec82430)] - doc: fix typo 'Can\'t not' => 'Can not' (#34) (dreamswhite <<dreamswhite@aliyun.com>>)
170+
* [[`004713c`](https://github.com/node-modules/myrds/commit/004713cf9a4aa2da84a9f02348996b1a8ec82430)] - doc: fix typo 'Can\'t not' => 'Can not' (#34) (dreamswhite <<dreamswhite@aliyun.com>>)
171171

172172
3.0.0 / 2017-04-02
173173
==================
@@ -219,7 +219,7 @@
219219
==================
220220

221221
* feat: add *beginTransactionScope(scope)
222-
* docs: require ali-rds
222+
* docs: require myrds
223223

224224
2.0.0 / 2015-06-08
225225
==================

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This software is licensed under the MIT License.
22

3-
Copyright (c) 2015-present ali-sdk and other contributors
3+
Copyright (c) 2024-present myrds and other contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# ali-rds
1+
# myrds
22

33
[![NPM version][npm-image]][npm-url]
4-
[![Node.js CI](https://github.com/ali-sdk/ali-rds/actions/workflows/nodejs.yml/badge.svg)](https://github.com/ali-sdk/ali-rds/actions/workflows/nodejs.yml)
4+
[![Node.js CI](https://github.com/node-modules/myrds/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/myrds/actions/workflows/nodejs.yml)
55
[![Test coverage][codecov-image]][codecov-url]
66
[![npm download][download-image]][download-url]
77

8-
[npm-image]: https://img.shields.io/npm/v/ali-rds.svg?style=flat-square
9-
[npm-url]: https://npmjs.org/package/ali-rds
10-
[codecov-image]: https://codecov.io/github/ali-sdk/ali-rds/coverage.svg?branch=master
11-
[codecov-url]: https://codecov.io/github/ali-sdk/ali-rds?branch=master
12-
[download-image]: https://img.shields.io/npm/dm/ali-rds.svg?style=flat-square
13-
[download-url]: https://npmjs.org/package/ali-rds
8+
[npm-image]: https://img.shields.io/npm/v/myrds.svg?style=flat-square
9+
[npm-url]: https://npmjs.org/package/myrds
10+
[codecov-image]: https://codecov.io/github/node-modules/myrds/coverage.svg?branch=master
11+
[codecov-url]: https://codecov.io/github/node-modules/myrds?branch=master
12+
[download-image]: https://img.shields.io/npm/dm/myrds.svg?style=flat-square
13+
[download-url]: https://npmjs.org/package/myrds
1414

15-
Aliyun RDS client.
15+
MY RDS client.
1616
RDS, Relational Database Service. Equal to well know Amazon [RDS](http://aws.amazon.com/rds/).
1717

1818
Support `MySQL` protocol only.
@@ -22,7 +22,7 @@ Support `MySQL` protocol only.
2222
### Create RDS instance
2323

2424
```ts
25-
import { RDSClient } from 'ali-rds';
25+
import { RDSClient } from 'myrds';
2626

2727
const db = new RDSClient({
2828
host: 'your-rds-address.mysql.rds.aliyuncs.com',

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "ali-rds",
3-
"version": "6.3.0",
4-
"description": "Aliyun RDS client",
2+
"name": "myrds",
3+
"version": "7.0.0",
4+
"description": "My RDS Client",
55
"main": "lib/client.js",
66
"types": "lib/client.d.ts",
77
"files": [
@@ -17,8 +17,7 @@
1717
"prepublishOnly": "npm run clean && npm run build"
1818
},
1919
"dependencies": {
20-
"@types/mysql": "^2.15.21",
21-
"mysql": "^2.18.1"
20+
"mysql2": "^3.9.1"
2221
},
2322
"devDependencies": {
2423
"@eggjs/tsconfig": "^1.3.2",
@@ -31,17 +30,18 @@
3130
"mm": "^3.3.0",
3231
"typescript": "^5.1.3"
3332
},
34-
"homepage": "https://github.com/ali-sdk/ali-rds",
33+
"homepage": "https://github.com/node-modules/myrds",
3534
"repository": {
3635
"type": "git",
37-
"url": "git://github.com/ali-sdk/ali-rds.git"
36+
"url": "git://github.com/node-modules/myrds.git"
3837
},
3938
"bugs": {
40-
"url": "https://github.com/ali-sdk/ali-rds/issues"
39+
"url": "https://github.com/node-modules/myrds/issues"
4140
},
4241
"keywords": [
43-
"ali-rds",
44-
"mysql"
42+
"myrds",
43+
"mysql",
44+
"mysql2"
4545
],
4646
"engines": {
4747
"node": ">= 16.17.0"

src/PoolConfig.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
import MySQLPoolConfig from 'mysql/lib/PoolConfig';
2-
import type { PoolConfig, ConnectionConfig } from 'mysql';
1+
import { ConnectionConfig } from 'mysql2';
2+
import type { PoolOptions } from 'mysql2';
33
import type { GetConnectionConfig } from './types';
44

5-
export class RDSPoolConfig extends MySQLPoolConfig {
5+
export class RDSPoolConfig {
66
#getConnectionConfig: GetConnectionConfig;
7+
#options: PoolOptions;
78

8-
constructor(options: PoolConfig, getConnectionConfig: GetConnectionConfig) {
9-
super(options);
9+
waitForConnections: boolean;
10+
connectionLimit: number;
11+
maxIdle: number;
12+
idleTimeout: number;
13+
queueLimit: number;
14+
15+
constructor(options: PoolOptions, getConnectionConfig: GetConnectionConfig) {
16+
this.#options = options;
1017
this.#getConnectionConfig = getConnectionConfig;
18+
19+
// mysql2 has not exports ConnectionConfig
20+
// so impl it mauanlly
21+
this.waitForConnections = options.waitForConnections === undefined ? true : Boolean(options.waitForConnections);
22+
this.connectionLimit = isNaN(options.connectionLimit!) ? 10 : Number(options.connectionLimit);
23+
this.maxIdle = isNaN(options.maxIdle!) ? this.connectionLimit : Number(options.maxIdle);
24+
this.idleTimeout = isNaN(options.idleTimeout!) ? 60000 : Number(options.idleTimeout);
25+
this.queueLimit = isNaN(options.queueLimit!) ? 0 : Number(options.queueLimit);
1126
}
1227

13-
newConnectionConfig(): ConnectionConfig {
14-
return {
15-
...super.newConnectionConfig(),
28+
get connectionConfig(): any {
29+
return new ConnectionConfig({
30+
...this.#options,
1631
...this.#getConnectionConfig(),
17-
};
32+
});
1833
}
1934
}

0 commit comments

Comments
 (0)