@pi-r/mongodb 0.5.6 → 0.5.8

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 CHANGED
@@ -235,9 +235,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
235
235
  if (length === 0) {
236
236
  return [];
237
237
  }
238
- let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
238
+ let parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss;
239
239
  if ((0, types_1.isPlainObject)(options)) {
240
- ({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
240
+ ({ parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss } = options);
241
241
  }
242
242
  else {
243
243
  if (typeof options === 'string') {
@@ -355,7 +355,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
355
355
  continue;
356
356
  }
357
357
  }
358
- else if (!aggregate && setResult()) {
358
+ else if (!aggregate && !update && setResult()) {
359
359
  continue;
360
360
  }
361
361
  if (!ignoreCache && outCacheMiss) {
@@ -485,10 +485,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
485
485
  }
486
486
  })
487
487
  .on('end', () => stream.destroy());
488
+ return;
488
489
  }
489
- else {
490
- rows = await cursor.toArray();
491
- }
490
+ rows = await cursor.toArray();
492
491
  }
493
492
  if (rows) {
494
493
  this.add(item, 4);
@@ -521,8 +520,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
521
520
  }
522
521
  }
523
522
  return this.processRows(batch, tasks, {
524
- disconnect: () => clients.forEach(item => item.close(true)),
525
- parallel
523
+ parallel,
524
+ errorAsEmpty,
525
+ disconnect: () => clients.forEach(item => item.close(true))
526
526
  }, outResult);
527
527
  }
528
528
  exports.executeBatchQuery = executeBatchQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mongodb",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
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.7.20",
25
- "@e-mc/request": "^0.7.20",
26
- "@e-mc/types": "^0.7.20",
24
+ "@e-mc/db": "^0.7.25",
25
+ "@e-mc/request": "^0.7.25",
26
+ "@e-mc/types": "^0.7.25",
27
27
  "mongodb": "^6.8.0"
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;