@pi-r/mongodb 0.10.3 → 0.10.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.
- package/client/index.js +8 -6
- 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,
|
|
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,8 +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 &&
|
|
316
|
-
|
|
315
|
+
if (caching && ignoreCache !== true && !streamRow) {
|
|
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 && typeof item.cacheObjectKey === 'string' ? targetObject.toString() + item.cacheObjectKey : '');
|
|
317
319
|
}
|
|
318
320
|
if (aggregate) {
|
|
319
321
|
pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
|
|
@@ -324,7 +326,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
324
326
|
}
|
|
325
327
|
if (queryString) {
|
|
326
328
|
const setResult = () => {
|
|
327
|
-
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))) {
|
|
328
330
|
++mongoCache;
|
|
329
331
|
if (parallel) {
|
|
330
332
|
tasks[i] = Promise.resolve(rows);
|
|
@@ -343,7 +345,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
343
345
|
continue;
|
|
344
346
|
}
|
|
345
347
|
}
|
|
346
|
-
else if (!aggregate && setResult()) {
|
|
348
|
+
else if (!aggregate && !update && setResult()) {
|
|
347
349
|
continue;
|
|
348
350
|
}
|
|
349
351
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -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((
|
|
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(this.statusType.INFO, output, "mongodb", 'runCommand');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.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.12.
|
|
24
|
-
"@e-mc/request": "^0.12.
|
|
25
|
-
"@e-mc/types": "^0.12.
|
|
23
|
+
"@e-mc/db": "^0.12.17",
|
|
24
|
+
"@e-mc/request": "^0.12.17",
|
|
25
|
+
"@e-mc/types": "^0.12.17",
|
|
26
26
|
"mongodb": "^6.19.0"
|
|
27
27
|
}
|
|
28
28
|
}
|