@pi-r/mongodb 0.11.2 → 0.11.4

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 +7 -8
  2. package/package.json +4 -4
package/client/index.js CHANGED
@@ -283,7 +283,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
283
283
  }
284
284
  for (let i = 0; i < length; ++i) {
285
285
  const item = batch[i];
286
- const { source, name, table, id, aggregate, distinct, sort, cacheObjectKey, ignoreCache } = item;
286
+ const { source, name, table, id, aggregate, distinct, sort, ignoreCache } = item;
287
287
  let { query, update, streamRow, limit = 0 } = item;
288
288
  if (!table) {
289
289
  const error = (0, types_1.errorMessage)(source, "Missing database table");
@@ -312,10 +312,10 @@ async function executeBatchQuery(batch, options = '', outResult) {
312
312
  streamRow = (0, types_1.asFunction)(streamRow);
313
313
  }
314
314
  let queryString = '', rows, pipeline;
315
- if (caching && ignoreCache !== true && (!targetObject || typeof cacheObjectKey === 'string') && !streamRow) {
315
+ if (caching && ignoreCache !== true && !streamRow) {
316
316
  const collection = item.client?.collection;
317
317
  const db = item.client?.db;
318
- queryString = (name || '') + '_' + table + (sort ? '_' + Db.asString(sort, true) : '') + '_' + (limit > 0 ? limit.toString() : '0') + (db ? Db.asString(db, true) : '') + (collection ? Db.asString(collection, true) : '') + (targetObject ? targetObject.toString() + cacheObjectKey : '');
318
+ queryString = (name || '') + '_' + table + (sort ? '_' + Db.asString(sort, true) : '') + '_' + (limit > 0 ? limit.toString() : '0') + (db ? Db.asString(db, true) : '') + (collection ? Db.asString(collection, true) : '') + (targetObject && typeof item.cacheObjectKey === 'string' ? targetObject.toString() + item.cacheObjectKey : '');
319
319
  }
320
320
  if (aggregate) {
321
321
  pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
@@ -326,7 +326,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
326
326
  }
327
327
  if (queryString) {
328
328
  const setResult = () => {
329
- if (ignoreCache !== 1 && (rows = this.getQueryResult(source, DbPool.sanitize(credential), queryString, cacheValue))) {
329
+ if (ignoreCache !== 1 && (rows = this.getQueryResult(source, DbPool.sanitize(mongoCredential || credential), queryString, cacheValue))) {
330
330
  ++mongoCache;
331
331
  if (parallel) {
332
332
  tasks[i] = Promise.resolve(rows);
@@ -345,7 +345,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
345
345
  continue;
346
346
  }
347
347
  }
348
- else if (!aggregate && setResult()) {
348
+ else if (!aggregate && !update && setResult()) {
349
349
  continue;
350
350
  }
351
351
  if (!ignoreCache && outCacheMiss) {
@@ -481,10 +481,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
481
481
  }
482
482
  })
483
483
  .on('end', () => stream.destroy());
484
+ return;
484
485
  }
485
- else {
486
- rows = await cursor.toArray();
487
- }
486
+ rows = await cursor.toArray();
488
487
  }
489
488
  if (rows) {
490
489
  this.add(item, 4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mongodb",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "MongoDB client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -20,9 +20,9 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/db": "^0.13.9",
24
- "@e-mc/request": "^0.13.9",
25
- "@e-mc/types": "^0.13.9",
23
+ "@e-mc/db": "^0.13.12",
24
+ "@e-mc/request": "^0.13.12",
25
+ "@e-mc/types": "^0.13.12",
26
26
  "mongodb": "^6.21.0"
27
27
  }
28
28
  }