@pi-r/mongodb 0.10.4 → 0.10.6
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 +10 -10
- package/package.json +4 -4
package/client/index.js
CHANGED
|
@@ -218,9 +218,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
218
218
|
if (length === 0) {
|
|
219
219
|
return [];
|
|
220
220
|
}
|
|
221
|
-
let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
221
|
+
let parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss;
|
|
222
222
|
if ((0, types_1.isPlainObject)(options)) {
|
|
223
|
-
({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
223
|
+
({ parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss } = options);
|
|
224
224
|
}
|
|
225
225
|
else {
|
|
226
226
|
if (typeof options === 'string') {
|
|
@@ -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,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 &&
|
|
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
|
-
|
|
486
|
-
rows = await cursor.toArray();
|
|
487
|
-
}
|
|
486
|
+
rows = await cursor.toArray();
|
|
488
487
|
}
|
|
489
488
|
if (rows) {
|
|
490
489
|
this.add(item, 4);
|
|
@@ -518,6 +517,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
518
517
|
}
|
|
519
518
|
return this.processRows(batch, tasks, clients.length === 0 ? parallel : {
|
|
520
519
|
parallel,
|
|
520
|
+
errorAsEmpty,
|
|
521
521
|
disconnect() {
|
|
522
522
|
for (const item of clients) {
|
|
523
523
|
void item.close(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
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.18",
|
|
24
|
+
"@e-mc/request": "^0.12.18",
|
|
25
|
+
"@e-mc/types": "^0.12.18",
|
|
26
26
|
"mongodb": "^6.19.0"
|
|
27
27
|
}
|
|
28
28
|
}
|