@pi-r/mongodb 0.2.3 → 0.3.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 +9 -9
- package/package.json +4 -4
package/client/index.js
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.getSortValue = exports.getFilterValue = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const mongodb = require("mongodb");
|
|
5
6
|
const types_1 = require("@e-mc/types");
|
|
6
7
|
const util_1 = require("@e-mc/db/util");
|
|
7
8
|
const Db = require("@e-mc/db");
|
|
8
9
|
const Request = require("@e-mc/request");
|
|
9
10
|
const DbPool = require('@e-mc/db/pool');
|
|
10
|
-
const MONGODB_V3 = Db.checkSemVer("mongodb" /* STRINGS.
|
|
11
|
-
const MONGODB_V330 = Db.checkSemVer("mongodb" /* STRINGS.
|
|
12
|
-
const MONGODB_V333 = Db.checkSemVer("mongodb" /* STRINGS.
|
|
13
|
-
const MONGODB_V360 = Db.checkSemVer("mongodb" /* STRINGS.
|
|
11
|
+
const MONGODB_V3 = Db.checkSemVer("mongodb" /* STRINGS.MODULE_NAME */, 1, 4);
|
|
12
|
+
const MONGODB_V330 = Db.checkSemVer("mongodb" /* STRINGS.MODULE_NAME */, '3.3.0');
|
|
13
|
+
const MONGODB_V333 = Db.checkSemVer("mongodb" /* STRINGS.MODULE_NAME */, '3.3.0', '3.3.3');
|
|
14
|
+
const MONGODB_V360 = Db.checkSemVer("mongodb" /* STRINGS.MODULE_NAME */, '3.6.0');
|
|
14
15
|
const MONGODB_TOPOLOGY = MONGODB_V3 && MONGODB_V330;
|
|
15
16
|
const MONGODB_NOPOOL = MONGODB_V3 && !MONGODB_V330;
|
|
16
17
|
class MongoDBPool extends DbPool {
|
|
@@ -342,8 +343,7 @@ function setCredential(item) {
|
|
|
342
343
|
}
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
|
-
|
|
346
|
-
new MongoDBPool(new db.MongoClient(item.uri, options), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
346
|
+
new MongoDBPool(new mongodb.MongoClient(item.uri, options), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
347
347
|
}
|
|
348
348
|
else {
|
|
349
349
|
pool.add(item);
|
|
@@ -364,7 +364,6 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
364
364
|
if (length === 0) {
|
|
365
365
|
return [];
|
|
366
366
|
}
|
|
367
|
-
const db = require("mongodb" /* STRINGS.PACKAGE_NAME */);
|
|
368
367
|
let parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
369
368
|
if ((0, types_1.isPlainObject)(options)) {
|
|
370
369
|
({ parallel, checkObject, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
@@ -412,7 +411,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
412
411
|
credential.options.maxPoolSize = size;
|
|
413
412
|
}
|
|
414
413
|
}
|
|
415
|
-
clients.push(client = await new
|
|
414
|
+
clients.push(client = await new mongodb.MongoClient(credential.uri, credential.options).connect());
|
|
416
415
|
}
|
|
417
416
|
if (connectOnce) {
|
|
418
417
|
mongoClient = client;
|
|
@@ -461,7 +460,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
461
460
|
pipeline = Array.isArray(aggregate) ? aggregate : aggregate.pipeline;
|
|
462
461
|
}
|
|
463
462
|
if (id && (!query || limit === 1) && !pipeline) {
|
|
464
|
-
query = { '_id': new
|
|
463
|
+
query = { '_id': new mongodb.ObjectId(id) };
|
|
465
464
|
limit = 1;
|
|
466
465
|
}
|
|
467
466
|
if (queryString) {
|
|
@@ -565,6 +564,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
565
564
|
if (updateOptions && coercing) {
|
|
566
565
|
(0, types_1.coerceObject)(updateOptions);
|
|
567
566
|
}
|
|
567
|
+
await collection.updateMany(filter, update, updateOptions);
|
|
568
568
|
}
|
|
569
569
|
cursor = collection.find(filter, command);
|
|
570
570
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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.
|
|
25
|
-
"@e-mc/request": "^0.
|
|
26
|
-
"@e-mc/types": "^0.
|
|
24
|
+
"@e-mc/db": "^0.6.0",
|
|
25
|
+
"@e-mc/request": "^0.6.0",
|
|
26
|
+
"@e-mc/types": "^0.6.0",
|
|
27
27
|
"mongodb": "^5.7.0"
|
|
28
28
|
}
|
|
29
29
|
}
|