@pi-r/mongodb 0.11.1 → 0.11.2

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 +5 -3
  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, client, cacheObjectKey, ignoreCache } = item;
286
+ const { source, name, table, id, aggregate, distinct, sort, cacheObjectKey, 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");
@@ -313,7 +313,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
313
313
  }
314
314
  let queryString = '', rows, pipeline;
315
315
  if (caching && ignoreCache !== true && (!targetObject || typeof cacheObjectKey === 'string') && !streamRow) {
316
- queryString = (name || '') + '_' + table + '_' + (limit > 0 ? limit.toString() : '0') + Db.asString(sort, true) + Db.asString(client, true) + (targetObject ? targetObject.toString() + cacheObjectKey : '');
316
+ const collection = item.client?.collection;
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 : '');
317
319
  }
318
320
  if (aggregate) {
319
321
  pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
@@ -529,7 +531,7 @@ async function checkTimeout(value, limit = 0) {
529
531
  async function initCollection(target, item) {
530
532
  const db = target.db(item.name, item.client?.db);
531
533
  if (item.command) {
532
- await Promise.all((!Array.isArray(item.command) ? [item.command] : item.command).map(async (cmd) => db.command(document, cmd)))
534
+ await Promise.all((Array.isArray(item.command) ? item.command : [item.command]).map((cmd) => db.command(cmd, { signal: this.signal })))
533
535
  .then(items => {
534
536
  for (const output of items) {
535
537
  this.addLog(4, output, "mongodb", 'runCommand');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mongodb",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
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.5",
24
- "@e-mc/request": "^0.13.5",
25
- "@e-mc/types": "^0.13.5",
23
+ "@e-mc/db": "^0.13.9",
24
+ "@e-mc/request": "^0.13.9",
25
+ "@e-mc/types": "^0.13.9",
26
26
  "mongodb": "^6.21.0"
27
27
  }
28
28
  }