@pi-r/mongodb 0.9.5 → 0.9.7
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
|
@@ -210,9 +210,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
210
210
|
if (length === 0) {
|
|
211
211
|
return [];
|
|
212
212
|
}
|
|
213
|
-
let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
213
|
+
let parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss;
|
|
214
214
|
if ((0, types_1.isPlainObject)(options)) {
|
|
215
|
-
({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
215
|
+
({ parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss } = options);
|
|
216
216
|
}
|
|
217
217
|
else {
|
|
218
218
|
if (typeof options === 'string') {
|
|
@@ -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,
|
|
274
|
+
const { source, name, table, id, aggregate, sort, 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");
|
|
@@ -300,10 +300,10 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
300
300
|
streamRow = (0, types_1.asFunction)(streamRow);
|
|
301
301
|
}
|
|
302
302
|
let queryString = '', rows, pipeline;
|
|
303
|
-
if (caching && ignoreCache !== true &&
|
|
303
|
+
if (caching && ignoreCache !== true && !streamRow) {
|
|
304
304
|
const collection = item.client?.collection;
|
|
305
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 : '');
|
|
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 && typeof item.cacheObjectKey === 'string' ? targetObject.toString() + item.cacheObjectKey : '');
|
|
307
307
|
}
|
|
308
308
|
if (aggregate) {
|
|
309
309
|
pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
|
|
@@ -314,7 +314,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
314
314
|
}
|
|
315
315
|
if (queryString) {
|
|
316
316
|
const setResult = () => {
|
|
317
|
-
if (ignoreCache !== 1 && (rows = this.getQueryResult(source, DbPool.sanitize(credential), queryString, cacheValue))) {
|
|
317
|
+
if (ignoreCache !== 1 && (rows = this.getQueryResult(source, DbPool.sanitize(mongoCredential || credential), queryString, cacheValue))) {
|
|
318
318
|
++mongoCache;
|
|
319
319
|
if (parallel) {
|
|
320
320
|
tasks[i] = Promise.resolve(rows);
|
|
@@ -333,7 +333,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
333
333
|
continue;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
else if (!aggregate && setResult()) {
|
|
336
|
+
else if (!aggregate && !update && setResult()) {
|
|
337
337
|
continue;
|
|
338
338
|
}
|
|
339
339
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -463,10 +463,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
463
463
|
}
|
|
464
464
|
})
|
|
465
465
|
.on('end', () => stream.destroy());
|
|
466
|
+
return;
|
|
466
467
|
}
|
|
467
|
-
|
|
468
|
-
rows = await cursor.toArray();
|
|
469
|
-
}
|
|
468
|
+
rows = await cursor.toArray();
|
|
470
469
|
}
|
|
471
470
|
if (rows) {
|
|
472
471
|
this.add(item, 4);
|
|
@@ -500,6 +499,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
500
499
|
}
|
|
501
500
|
return this.processRows(batch, tasks, {
|
|
502
501
|
parallel,
|
|
502
|
+
errorAsEmpty,
|
|
503
503
|
disconnect() {
|
|
504
504
|
for (const item of clients) {
|
|
505
505
|
void item.close(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
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.
|
|
24
|
-
"@e-mc/request": "^0.11.
|
|
25
|
-
"@e-mc/types": "^0.11.
|
|
23
|
+
"@e-mc/db": "^0.11.19",
|
|
24
|
+
"@e-mc/request": "^0.11.19",
|
|
25
|
+
"@e-mc/types": "^0.11.19",
|
|
26
26
|
"mongodb": "^6.15.0"
|
|
27
27
|
}
|
|
28
28
|
}
|