@pi-r/mongodb 0.2.1 → 0.2.3
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 +23 -9
- package/package.json +5 -5
- package/types/index.d.ts +3 -2
package/client/index.js
CHANGED
|
@@ -58,18 +58,26 @@ class MongoDBPool extends DbPool {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
const POOL_STATE = {};
|
|
61
|
+
const POOL_UNUSED = ['maxPoolSize', 'minPoolSize', 'maxConnecting', 'maxIdleTimeMS', 'waitQueueTimeoutMS', 'serverSelectionTimeoutMS', 'heartbeatFrequencyMS', 'minHeartbeatFrequencyMS', 'keepAliveInitialDelay', 'compressors', 'zlibCompressionLevel', 'srvMaxHosts'];
|
|
61
62
|
function removePoolProperties(credential) {
|
|
62
|
-
|
|
63
|
+
const options = credential.options;
|
|
63
64
|
if (options && !credential.uuidKey) {
|
|
65
|
+
let result;
|
|
64
66
|
if (MONGODB_V360) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
|
|
68
|
+
const attr = POOL_UNUSED[i];
|
|
69
|
+
if (attr in credential) {
|
|
70
|
+
result || (result = { ...options });
|
|
71
|
+
delete result[attr];
|
|
72
|
+
}
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
else if ('poolSize' in options || 'minSize' in options) {
|
|
70
|
-
|
|
76
|
+
result = { ...options, poolSize: undefined, minSize: undefined };
|
|
77
|
+
}
|
|
78
|
+
if (result) {
|
|
79
|
+
return { uri: credential.uri, options: result };
|
|
71
80
|
}
|
|
72
|
-
return { uri: credential.uri, options };
|
|
73
81
|
}
|
|
74
82
|
return credential;
|
|
75
83
|
}
|
|
@@ -524,11 +532,14 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
524
532
|
if ((0, types_1.isArray)(update)) {
|
|
525
533
|
commandType = this.commandType.INSERT;
|
|
526
534
|
const insertOptions = item.execute?.insert;
|
|
527
|
-
if (insertOptions) {
|
|
528
|
-
|
|
535
|
+
if (insertOptions && coercing) {
|
|
536
|
+
(0, types_1.coerceObject)(insertOptions);
|
|
537
|
+
}
|
|
538
|
+
if (update.length === 1) {
|
|
539
|
+
await collection.insertOne(update[0], insertOptions);
|
|
529
540
|
}
|
|
530
541
|
else {
|
|
531
|
-
await collection.insertMany(update);
|
|
542
|
+
await collection.insertMany(update, insertOptions);
|
|
532
543
|
}
|
|
533
544
|
update = undefined;
|
|
534
545
|
}
|
|
@@ -550,7 +561,10 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
550
561
|
else {
|
|
551
562
|
if (update) {
|
|
552
563
|
commandType = this.commandType.UPDATE;
|
|
553
|
-
|
|
564
|
+
const updateOptions = item.execute?.update;
|
|
565
|
+
if (updateOptions && coercing) {
|
|
566
|
+
(0, types_1.coerceObject)(updateOptions);
|
|
567
|
+
}
|
|
554
568
|
}
|
|
555
569
|
cursor = collection.find(filter, command);
|
|
556
570
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/mongodb",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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.5.
|
|
25
|
-
"@e-mc/request": "^0.5.
|
|
26
|
-
"@e-mc/types": "^0.5.
|
|
27
|
-
"mongodb": "^5.
|
|
24
|
+
"@e-mc/db": "^0.5.3",
|
|
25
|
+
"@e-mc/request": "^0.5.3",
|
|
26
|
+
"@e-mc/types": "^0.5.3",
|
|
27
|
+
"mongodb": "^5.7.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { DbDataSource } from '@e-mc/types/lib/squared';
|
|
|
2
2
|
|
|
3
3
|
import type { CascadeAction, ServerAuth } from '@e-mc/types/lib/db';
|
|
4
4
|
|
|
5
|
-
import type { AggregateOptions,
|
|
5
|
+
import type { AggregateOptions, CollectionOptions, CommandOperationOptions, DbOptions, Document, Filter, MongoClientOptions, OptionalUnlessRequiredId, Sort, SortDirection, UpdateFilter } from 'mongodb';
|
|
6
6
|
|
|
7
7
|
export interface MongoDBDataSource extends DbDataSource<Filter<Document> | MongoDBQueryWithOptions, MongoClientOptions, UpdateFilter<Document> | OptionalUnlessRequiredId<unknown>[], string | MongoDBCredential, string>, MongoDBClientDBOptions, CascadeAction {
|
|
8
8
|
source: "mongodb";
|
|
@@ -28,7 +28,8 @@ export interface MongoDBClientDBOptions {
|
|
|
28
28
|
collection?: CollectionOptions;
|
|
29
29
|
};
|
|
30
30
|
execute?: {
|
|
31
|
-
insert?:
|
|
31
|
+
insert?: CommandOperationOptions;
|
|
32
|
+
update?: CommandOperationOptions;
|
|
32
33
|
};
|
|
33
34
|
aggregate?: MongoDBAggregate;
|
|
34
35
|
sort?: Sort | string | MongoDBSortValue;
|