@pi-r/mongodb 0.8.5 → 0.8.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
|
@@ -209,9 +209,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
209
209
|
if (length === 0) {
|
|
210
210
|
return [];
|
|
211
211
|
}
|
|
212
|
-
let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
212
|
+
let parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss;
|
|
213
213
|
if ((0, types_1.isPlainObject)(options)) {
|
|
214
|
-
({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
214
|
+
({ parallel, checkObject, connectOnce, errorQuery, errorAsEmpty, sessionKey, outCacheMiss } = options);
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
217
|
if (typeof options === 'string') {
|
|
@@ -270,7 +270,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
270
270
|
}
|
|
271
271
|
for (let i = 0; i < length; ++i) {
|
|
272
272
|
const item = batch[i];
|
|
273
|
-
const { source, name, table, id, aggregate, sort, client,
|
|
273
|
+
const { source, name, table, id, aggregate, sort, client, ignoreCache } = item;
|
|
274
274
|
let { query, update, streamRow, limit = 0 } = item;
|
|
275
275
|
if (!table) {
|
|
276
276
|
const error = (0, types_1.errorMessage)(source, "Missing database table");
|
|
@@ -302,8 +302,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
302
302
|
streamRow = coercing && (0, types_1.asFunction)(streamRow);
|
|
303
303
|
}
|
|
304
304
|
let queryString = '', rows, pipeline;
|
|
305
|
-
if (caching && ignoreCache !== true &&
|
|
306
|
-
queryString = (name || '') + '_' + table + '_' + limit + Db.asString(sort, true) + Db.asString(client, true) + (targetObject ? targetObject.toString() + cacheObjectKey : '');
|
|
305
|
+
if (caching && ignoreCache !== true && !streamRow) {
|
|
306
|
+
queryString = (name || '') + '_' + table + '_' + limit + Db.asString(sort, true) + Db.asString(client, 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) {
|
|
@@ -471,10 +471,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
471
471
|
}
|
|
472
472
|
})
|
|
473
473
|
.on('end', () => stream.destroy());
|
|
474
|
+
return;
|
|
474
475
|
}
|
|
475
|
-
|
|
476
|
-
rows = await cursor.toArray();
|
|
477
|
-
}
|
|
476
|
+
rows = await cursor.toArray();
|
|
478
477
|
}
|
|
479
478
|
if (rows) {
|
|
480
479
|
this.add(item, 4);
|
|
@@ -508,6 +507,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
508
507
|
}
|
|
509
508
|
return this.processRows(batch, tasks, {
|
|
510
509
|
parallel,
|
|
510
|
+
errorAsEmpty,
|
|
511
511
|
disconnect() {
|
|
512
512
|
for (const item of clients) {
|
|
513
513
|
void item.close(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "MongoDB client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/db": "^0.10.
|
|
25
|
-
"@e-mc/request": "^0.10.
|
|
26
|
-
"@e-mc/types": "^0.10.
|
|
24
|
+
"@e-mc/db": "^0.10.22",
|
|
25
|
+
"@e-mc/request": "^0.10.22",
|
|
26
|
+
"@e-mc/types": "^0.10.22",
|
|
27
27
|
"mongodb": "^6.9.0"
|
|
28
28
|
}
|
|
29
29
|
}
|