@pi-r/mongodb 0.9.4 → 0.9.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 +8 -6
- package/package.json +4 -4
package/client/index.js
CHANGED
|
@@ -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,8 +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 &&
|
|
304
|
-
|
|
303
|
+
if (caching && ignoreCache !== true && !streamRow) {
|
|
304
|
+
const collection = item.client?.collection;
|
|
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 && typeof item.cacheObjectKey === 'string' ? targetObject.toString() + item.cacheObjectKey : '');
|
|
305
307
|
}
|
|
306
308
|
if (aggregate) {
|
|
307
309
|
pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
|
|
@@ -312,7 +314,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
312
314
|
}
|
|
313
315
|
if (queryString) {
|
|
314
316
|
const setResult = () => {
|
|
315
|
-
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))) {
|
|
316
318
|
++mongoCache;
|
|
317
319
|
if (parallel) {
|
|
318
320
|
tasks[i] = Promise.resolve(rows);
|
|
@@ -331,7 +333,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
331
333
|
continue;
|
|
332
334
|
}
|
|
333
335
|
}
|
|
334
|
-
else if (!aggregate && setResult()) {
|
|
336
|
+
else if (!aggregate && !update && setResult()) {
|
|
335
337
|
continue;
|
|
336
338
|
}
|
|
337
339
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -511,7 +513,7 @@ async function checkTimeout(value, limit = 0) {
|
|
|
511
513
|
async function initCollection(target, item) {
|
|
512
514
|
const db = target.db(item.name, item.client?.db);
|
|
513
515
|
if (item.command) {
|
|
514
|
-
await Promise.all((
|
|
516
|
+
await Promise.all((Array.isArray(item.command) ? item.command : [item.command]).map((cmd) => db.command(cmd, { signal: this.signal })))
|
|
515
517
|
.then(items => {
|
|
516
518
|
for (const output of items) {
|
|
517
519
|
this.addLog(this.statusType.INFO, output, this.moduleName, 'runCommand');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.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.11.
|
|
24
|
-
"@e-mc/request": "^0.11.
|
|
25
|
-
"@e-mc/types": "^0.11.
|
|
23
|
+
"@e-mc/db": "^0.11.18",
|
|
24
|
+
"@e-mc/request": "^0.11.18",
|
|
25
|
+
"@e-mc/types": "^0.11.18",
|
|
26
26
|
"mongodb": "^6.15.0"
|
|
27
27
|
}
|
|
28
28
|
}
|