@pi-r/mongodb 0.2.13 → 0.2.15

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
@@ -369,9 +369,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
369
369
  return [];
370
370
  }
371
371
  const db = require("mongodb");
372
- let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
372
+ let parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss;
373
373
  if ((0, types_1.isPlainObject)(options)) {
374
- ({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
374
+ ({ parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss } = options);
375
375
  }
376
376
  else {
377
377
  if (typeof options === 'string') {
@@ -489,7 +489,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
489
489
  continue;
490
490
  }
491
491
  }
492
- else if (!aggregate && setResult()) {
492
+ else if (!aggregate && !update && setResult()) {
493
493
  continue;
494
494
  }
495
495
  if (!ignoreCache && outCacheMiss) {
@@ -618,10 +618,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
618
618
  }
619
619
  })
620
620
  .on('end', () => stream.destroy());
621
+ return;
621
622
  }
622
- else {
623
- rows = await cursor.toArray();
624
- }
623
+ rows = await cursor.toArray();
625
624
  }
626
625
  if (rows) {
627
626
  this.add(item, 4);
@@ -654,8 +653,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
654
653
  }
655
654
  }
656
655
  return this.processRows(batch, tasks, {
657
- disconnect: () => clients.forEach(item => item.close(true)),
658
- parallel
656
+ parallel,
657
+ errorAsEmpty,
658
+ disconnect: () => clients.forEach(item => item.close(true))
659
659
  }, outResult);
660
660
  }
661
661
  exports.executeBatchQuery = executeBatchQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mongodb",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
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.18",
25
- "@e-mc/request": "^0.5.18",
26
- "@e-mc/types": "^0.5.18",
24
+ "@e-mc/db": "^0.5.23",
25
+ "@e-mc/request": "^0.5.23",
26
+ "@e-mc/types": "^0.5.23",
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;