@pi-r/mariadb 0.2.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client/index.js +13 -5
  2. package/package.json +4 -4
package/client/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = exports.setAuthentication = void 0;
4
+ const mariadb = require("mariadb");
4
5
  const util_1 = require("@e-mc/db/util");
5
6
  const types_1 = require("@e-mc/types");
6
7
  const Db = require("@e-mc/db");
@@ -109,18 +110,26 @@ function setCredential(item) {
109
110
  }
110
111
  const poolKey = getPoolKey(credential);
111
112
  if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
112
- const { createPool } = require("mariadb" /* STRINGS.PACKAGE_NAME */);
113
113
  const config = this.getPoolConfig("mariadb" /* STRINGS.MODULE_NAME */, password);
114
114
  if (config) {
115
- const { max, idle } = config;
115
+ const { min, max, idle, timeout, socket_timeout } = config;
116
+ if (min >= 0) {
117
+ credential.minimumIdle ?? (credential.minimumIdle = min);
118
+ }
116
119
  if (max > 0) {
117
120
  credential.connectionLimit ?? (credential.connectionLimit = max);
118
121
  }
119
122
  if (idle >= 0) {
120
123
  credential.idleTimeout ?? (credential.idleTimeout = idle);
121
124
  }
125
+ if (timeout > 0) {
126
+ credential.connectTimeout ?? (credential.connectTimeout = timeout);
127
+ }
128
+ if (socket_timeout > 0) {
129
+ credential.socketTimeout ?? (credential.socketTimeout = socket_timeout);
130
+ }
122
131
  }
123
- new MariaDBPool(createPool(removeUUIDKey(credential)), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
132
+ new MariaDBPool(mariadb.createPool(removeUUIDKey(credential)), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
124
133
  }
125
134
  else {
126
135
  pool.add(item);
@@ -137,7 +146,6 @@ async function executeBatchQuery(batch, options = '', outResult) {
137
146
  if (length === 0) {
138
147
  return [];
139
148
  }
140
- const db = require("mariadb" /* STRINGS.PACKAGE_NAME */);
141
149
  let parallel, connectOnce, errorQuery, sessionKey, outCacheMiss;
142
150
  if ((0, types_1.isPlainObject)(options)) {
143
151
  ({ parallel, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
@@ -203,7 +211,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
203
211
  }
204
212
  }
205
213
  if (!client) {
206
- clients.push(client = await db.createConnection(removeUUIDKey(mariaDBCredential || credential)));
214
+ clients.push(client = await mariadb.createConnection(removeUUIDKey(mariaDBCredential || credential)));
207
215
  }
208
216
  if (connectOnce) {
209
217
  if (!parallel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mariadb",
3
- "version": "0.2.4",
3
+ "version": "0.5.0",
4
4
  "description": "MariaDB client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.5.3",
25
- "@e-mc/types": "^0.5.3",
26
- "mariadb": "^3.2.0"
24
+ "@e-mc/db": "^0.7.0",
25
+ "@e-mc/types": "^0.7.0",
26
+ "mariadb": "^3.2.2"
27
27
  }
28
28
  }