@pi-r/mongodb 0.12.5 → 0.13.0
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 -5
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -331,9 +331,10 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
331
331
|
}
|
|
332
332
|
let queryString = '', cacheCredential, rows, pipeline;
|
|
333
333
|
if (caching && ignoreCache !== true && !streamRow) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
queryString = Db.keyForResult(name, table, item.withFields, sort, Math.max(0, limit));
|
|
335
|
+
if (item.client) {
|
|
336
|
+
queryString = Db.keyForResult(queryString, item.client.db, item.client.collection);
|
|
337
|
+
}
|
|
337
338
|
}
|
|
338
339
|
if (aggregate) {
|
|
339
340
|
pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
|
|
@@ -345,6 +346,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
345
346
|
if (queryString) {
|
|
346
347
|
const setResult = () => {
|
|
347
348
|
if (ignoreCache !== 1 && (rows = this.getQueryResult(source, cacheCredential, queryString, cacheValue))) {
|
|
349
|
+
if (targetObject) {
|
|
350
|
+
rows = targetObject(item, rows);
|
|
351
|
+
}
|
|
348
352
|
++mongoCache;
|
|
349
353
|
if (parallel) {
|
|
350
354
|
tasks[i] = Promise.resolve(rows);
|
|
@@ -358,7 +362,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
358
362
|
return false;
|
|
359
363
|
};
|
|
360
364
|
if (pipeline || query || distinct) {
|
|
361
|
-
queryString
|
|
365
|
+
queryString = Db.keyForResult(queryString, aggregate || query || distinct);
|
|
362
366
|
cacheCredential = DbPool.sanitize(mongoCredential || credential, sortKeys);
|
|
363
367
|
if ((aggregate || distinct || !update) && setResult()) {
|
|
364
368
|
continue;
|
|
@@ -512,10 +516,11 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
512
516
|
}
|
|
513
517
|
if (rows) {
|
|
514
518
|
this.add(item, 4);
|
|
519
|
+
rows = this.setQueryResult(source, cacheCredential, queryString, rows, cacheValue);
|
|
515
520
|
if (targetObject) {
|
|
516
521
|
rows = targetObject(item, rows);
|
|
517
522
|
}
|
|
518
|
-
resolve(
|
|
523
|
+
resolve(rows);
|
|
519
524
|
}
|
|
520
525
|
else {
|
|
521
526
|
throw errorMessage(source, "Missing database query");
|