@pi-r/mongodb 0.9.4 → 0.9.5

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
@@ -271,7 +271,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
271
271
  }
272
272
  for (let i = 0; i < length; ++i) {
273
273
  const item = batch[i];
274
- const { source, name, table, id, aggregate, sort, client, cacheObjectKey, ignoreCache } = item;
274
+ const { source, name, table, id, aggregate, sort, cacheObjectKey, ignoreCache } = item;
275
275
  let { query, update, streamRow, limit = 0 } = item;
276
276
  if (!table) {
277
277
  const error = (0, types_1.errorMessage)(source, "Missing database table");
@@ -301,7 +301,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
301
301
  }
302
302
  let queryString = '', rows, pipeline;
303
303
  if (caching && ignoreCache !== true && (!targetObject || typeof cacheObjectKey === 'string') && !streamRow) {
304
- queryString = (name || '') + '_' + table + '_' + limit + Db.asString(sort, true) + Db.asString(client, true) + (targetObject ? targetObject.toString() + cacheObjectKey : '');
304
+ const collection = item.client?.collection;
305
+ const db = item.client?.db;
306
+ 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 : '');
305
307
  }
306
308
  if (aggregate) {
307
309
  pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
@@ -511,7 +513,7 @@ async function checkTimeout(value, limit = 0) {
511
513
  async function initCollection(target, item) {
512
514
  const db = target.db(item.name, item.client?.db);
513
515
  if (item.command) {
514
- await Promise.all((!Array.isArray(item.command) ? [item.command] : item.command).map(async (cmd) => db.command(document, cmd)))
516
+ await Promise.all((Array.isArray(item.command) ? item.command : [item.command]).map((cmd) => db.command(cmd, { signal: this.signal })))
515
517
  .then(items => {
516
518
  for (const output of items) {
517
519
  this.addLog(this.statusType.INFO, output, this.moduleName, 'runCommand');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mongodb",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
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.11.5",
24
- "@e-mc/request": "^0.11.5",
25
- "@e-mc/types": "^0.11.5",
23
+ "@e-mc/db": "^0.11.17",
24
+ "@e-mc/request": "^0.11.17",
25
+ "@e-mc/types": "^0.11.17",
26
26
  "mongodb": "^6.15.0"
27
27
  }
28
28
  }