@pi-r/mongodb 0.2.13 → 0.2.14
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.
- package/client/index.js +1 -1
- package/package.json +4 -4
- package/client/pool.js +0 -65
package/client/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "MongoDB client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/db": "^0.5.
|
|
25
|
-
"@e-mc/request": "^0.5.
|
|
26
|
-
"@e-mc/types": "^0.5.
|
|
24
|
+
"@e-mc/db": "^0.5.21",
|
|
25
|
+
"@e-mc/request": "^0.5.21",
|
|
26
|
+
"@e-mc/types": "^0.5.21",
|
|
27
27
|
"mongodb": "^5.9.2"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/client/pool.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const util_1 = require("@e-mc/db/util");
|
|
3
|
-
const DbPool = require('@e-mc/db/pool');
|
|
4
|
-
const POOL_ACTIVE = new WeakSet();
|
|
5
|
-
class MongoDBPool extends DbPool {
|
|
6
|
-
static CACHE_UNUSED = ['maxPoolSize', 'minPoolSize', 'connectTimeoutMS', 'socketTimeoutMS', 'maxConnecting', 'maxIdleTimeMS', 'waitQueueTimeoutMS', 'maxStalenessSeconds', 'localThresholdMS', 'serverSelectionTimeoutMS', 'heartbeatFrequencyMS', 'minHeartbeatFrequencyMS', 'timeoutMS', 'compressors', 'zlibCompressionLevel', 'srvMaxHosts', 'mongodbLogPath', 'mongodbLogComponentSeverities', 'mongodbLogMaxDocumentLength'];
|
|
7
|
-
static CACHE_IGNORE = ['pkFactory'];
|
|
8
|
-
static asString(credential) {
|
|
9
|
-
const { options, uri } = credential;
|
|
10
|
-
if (uri && options) {
|
|
11
|
-
return uri + JSON.stringify(options);
|
|
12
|
-
}
|
|
13
|
-
return super.asString(credential);
|
|
14
|
-
}
|
|
15
|
-
static sanitize(credential) {
|
|
16
|
-
if (!this.canCache(credential)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const target = credential.options;
|
|
20
|
-
if (!target || !POOL_ACTIVE.has(credential) || credential.uuidKey) {
|
|
21
|
-
return credential;
|
|
22
|
-
}
|
|
23
|
-
const options = super.sanitize(target);
|
|
24
|
-
return options !== target ? { uri: credential.uri, options } : credential;
|
|
25
|
-
}
|
|
26
|
-
async detach(force) {
|
|
27
|
-
this.remove();
|
|
28
|
-
if (this.closed) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
return this.close(force);
|
|
32
|
-
}
|
|
33
|
-
get closeable() {
|
|
34
|
-
const topology = this.client.topology;
|
|
35
|
-
return topology ? super.closeable || topology.s.state === 'closing' : true;
|
|
36
|
-
}
|
|
37
|
-
async getConnection(credential) {
|
|
38
|
-
if (credential) {
|
|
39
|
-
POOL_ACTIVE.add(credential);
|
|
40
|
-
}
|
|
41
|
-
return this.client.connect();
|
|
42
|
-
}
|
|
43
|
-
async close(force = false) {
|
|
44
|
-
return this.client.close(force);
|
|
45
|
-
}
|
|
46
|
-
isEmpty() {
|
|
47
|
-
if (this.closed) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
const topology = this.client.topology;
|
|
51
|
-
if (topology) {
|
|
52
|
-
const name = Object.getOwnPropertySymbols(topology).find(sym => sym.toString() === 'Symbol(waitQueue)');
|
|
53
|
-
return (0, util_1.checkEmpty)(name ? topology[name] : topology.s.servers);
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
get closed() {
|
|
58
|
-
const topology = this.client.topology;
|
|
59
|
-
if (topology && (this.success > 0 || this.failed > 0)) {
|
|
60
|
-
return topology.isDestroyed();
|
|
61
|
-
}
|
|
62
|
-
return this.client.s?.hasBeenClosed === true;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
module.exports = MongoDBPool;
|