nx-mongo 3.6.0 → 3.8.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/README.md +206 -19
- package/dist/simpleMongoHelper.d.ts +68 -15
- package/dist/simpleMongoHelper.d.ts.map +1 -1
- package/dist/simpleMongoHelper.js +200 -60
- package/dist/simpleMongoHelper.js.map +1 -1
- package/package.json +1 -1
- package/src/simpleMongoHelper.ts +254 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleMongoHelper.d.ts","sourceRoot":"","sources":["../src/simpleMongoHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAc,MAAM,EAAE,YAAY,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGvL,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CA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AAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,aAAa,CAAC;QACxB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GACA,OAAO,CAAC,gBAAgB,CAAC;IA6K5B;;;;;;;;;;;OAWG;IACG,UAAU,CACd,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,GAAG,EAAE,EAChB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IA0C5B;;;;;;OAMG;IACG,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAqWzF;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAuEvB;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBjC;;;;OAIG;IACI,iBAAiB,IAAI,IAAI;IAMhC;;;OAGG;IACI,KAAK,IAAI,EAAE;IAOlB;;;;;;;OAOG;IACH,OAAO,CAAC,iCAAiC;IAmBzC;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAqDvB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;;;;;OAQG;IACI,iBAAiB,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,EAAE;CAGjF"}
|
|
@@ -195,13 +195,14 @@ class ProgressAPIImpl {
|
|
|
195
195
|
* Ensures the progress collection and unique index exist.
|
|
196
196
|
* Called lazily on first use.
|
|
197
197
|
*/
|
|
198
|
-
async ensureProgressIndex(session) {
|
|
198
|
+
async ensureProgressIndex(session, database, ref, type) {
|
|
199
199
|
if (this.indexEnsured) {
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
this.helper.ensureInitialized();
|
|
203
203
|
try {
|
|
204
|
-
const
|
|
204
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
205
|
+
const collection = db.collection(this.config.collection);
|
|
205
206
|
const indexes = await collection.indexes();
|
|
206
207
|
// Build index spec from uniqueIndexKeys
|
|
207
208
|
const indexSpec = {};
|
|
@@ -253,12 +254,16 @@ class ProgressAPIImpl {
|
|
|
253
254
|
return filter;
|
|
254
255
|
}
|
|
255
256
|
async isCompleted(key, options) {
|
|
256
|
-
|
|
257
|
+
const database = options?.database;
|
|
258
|
+
const ref = options?.ref;
|
|
259
|
+
const type = options?.type;
|
|
260
|
+
await this.ensureProgressIndex(options?.session, database, ref, type);
|
|
257
261
|
this.helper.ensureInitialized();
|
|
258
262
|
const provider = this.resolveProvider(options);
|
|
259
263
|
const process = options?.process;
|
|
260
264
|
const filter = this.buildFilter(key, process, provider);
|
|
261
|
-
const
|
|
265
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
266
|
+
const collection = db.collection(this.config.collection);
|
|
262
267
|
const findOptions = {};
|
|
263
268
|
if (options?.session) {
|
|
264
269
|
findOptions.session = options.session;
|
|
@@ -267,12 +272,16 @@ class ProgressAPIImpl {
|
|
|
267
272
|
return record?.completed === true;
|
|
268
273
|
}
|
|
269
274
|
async start(identity, options) {
|
|
270
|
-
|
|
275
|
+
const database = options?.database;
|
|
276
|
+
const ref = options?.ref;
|
|
277
|
+
const type = options?.type;
|
|
278
|
+
await this.ensureProgressIndex(options?.session, database, ref, type);
|
|
271
279
|
this.helper.ensureInitialized();
|
|
272
280
|
const provider = this.resolveProvider({ provider: identity.provider });
|
|
273
281
|
const process = identity.process;
|
|
274
282
|
const filter = this.buildFilter(identity.key, process, provider);
|
|
275
|
-
const
|
|
283
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
284
|
+
const collection = db.collection(this.config.collection);
|
|
276
285
|
const update = {
|
|
277
286
|
$set: {
|
|
278
287
|
key: identity.key,
|
|
@@ -296,12 +305,16 @@ class ProgressAPIImpl {
|
|
|
296
305
|
await collection.updateOne(filter, update, updateOptions);
|
|
297
306
|
}
|
|
298
307
|
async complete(identity, options) {
|
|
299
|
-
|
|
308
|
+
const database = options?.database;
|
|
309
|
+
const ref = options?.ref;
|
|
310
|
+
const type = options?.type;
|
|
311
|
+
await this.ensureProgressIndex(options?.session, database, ref, type);
|
|
300
312
|
this.helper.ensureInitialized();
|
|
301
313
|
const provider = this.resolveProvider({ provider: identity.provider });
|
|
302
314
|
const process = identity.process;
|
|
303
315
|
const filter = this.buildFilter(identity.key, process, provider);
|
|
304
|
-
const
|
|
316
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
317
|
+
const collection = db.collection(this.config.collection);
|
|
305
318
|
const update = {
|
|
306
319
|
$set: {
|
|
307
320
|
key: identity.key,
|
|
@@ -329,7 +342,10 @@ class ProgressAPIImpl {
|
|
|
329
342
|
await collection.updateOne(filter, update, updateOptions);
|
|
330
343
|
}
|
|
331
344
|
async getCompleted(options) {
|
|
332
|
-
|
|
345
|
+
const database = options?.database;
|
|
346
|
+
const ref = options?.ref;
|
|
347
|
+
const type = options?.type;
|
|
348
|
+
await this.ensureProgressIndex(options?.session, database, ref, type);
|
|
333
349
|
this.helper.ensureInitialized();
|
|
334
350
|
const provider = this.resolveProvider(options);
|
|
335
351
|
const process = options?.process;
|
|
@@ -340,7 +356,8 @@ class ProgressAPIImpl {
|
|
|
340
356
|
if (provider !== undefined) {
|
|
341
357
|
filter.provider = provider;
|
|
342
358
|
}
|
|
343
|
-
const
|
|
359
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
360
|
+
const collection = db.collection(this.config.collection);
|
|
344
361
|
const findOptions = { projection: { key: 1, name: 1, completedAt: 1 } };
|
|
345
362
|
if (options?.session) {
|
|
346
363
|
findOptions.session = options.session;
|
|
@@ -353,7 +370,10 @@ class ProgressAPIImpl {
|
|
|
353
370
|
}));
|
|
354
371
|
}
|
|
355
372
|
async getProgress(options) {
|
|
356
|
-
|
|
373
|
+
const database = options?.database;
|
|
374
|
+
const ref = options?.ref;
|
|
375
|
+
const type = options?.type;
|
|
376
|
+
await this.ensureProgressIndex(options?.session, database, ref, type);
|
|
357
377
|
this.helper.ensureInitialized();
|
|
358
378
|
const provider = this.resolveProvider(options);
|
|
359
379
|
const process = options?.process;
|
|
@@ -364,7 +384,8 @@ class ProgressAPIImpl {
|
|
|
364
384
|
if (provider !== undefined) {
|
|
365
385
|
filter.provider = provider;
|
|
366
386
|
}
|
|
367
|
-
const
|
|
387
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
388
|
+
const collection = db.collection(this.config.collection);
|
|
368
389
|
const findOptions = {};
|
|
369
390
|
if (options?.session) {
|
|
370
391
|
findOptions.session = options.session;
|
|
@@ -372,12 +393,16 @@ class ProgressAPIImpl {
|
|
|
372
393
|
return await collection.find(filter, findOptions).toArray();
|
|
373
394
|
}
|
|
374
395
|
async reset(key, options) {
|
|
375
|
-
|
|
396
|
+
const database = options?.database;
|
|
397
|
+
const ref = options?.ref;
|
|
398
|
+
const type = options?.type;
|
|
399
|
+
await this.ensureProgressIndex(options?.session, database, ref, type);
|
|
376
400
|
this.helper.ensureInitialized();
|
|
377
401
|
const provider = this.resolveProvider(options);
|
|
378
402
|
const process = options?.process;
|
|
379
403
|
const filter = this.buildFilter(key, process, provider);
|
|
380
|
-
const
|
|
404
|
+
const db = this.helper.getDatabaseByName(database, ref, type);
|
|
405
|
+
const collection = db.collection(this.config.collection);
|
|
381
406
|
const update = {
|
|
382
407
|
$set: {
|
|
383
408
|
completed: false,
|
|
@@ -402,7 +427,8 @@ class SimpleMongoHelper {
|
|
|
402
427
|
this.config = null;
|
|
403
428
|
this.cleanupRegistered = false;
|
|
404
429
|
this.isDisconnecting = false;
|
|
405
|
-
|
|
430
|
+
// Strip database name from connection string if present
|
|
431
|
+
this.connectionString = this.stripDatabaseFromConnectionString(connectionString);
|
|
406
432
|
this.retryOptions = {
|
|
407
433
|
maxRetries: retryOptions?.maxRetries ?? 3,
|
|
408
434
|
retryDelay: retryOptions?.retryDelay ?? 1000,
|
|
@@ -505,9 +531,8 @@ class SimpleMongoHelper {
|
|
|
505
531
|
connectTimeoutMS: 5000
|
|
506
532
|
});
|
|
507
533
|
await testClient.connect();
|
|
508
|
-
// Try to ping the server
|
|
509
|
-
const
|
|
510
|
-
const testDb = testClient.db(dbName);
|
|
534
|
+
// Try to ping the server using 'admin' database (default)
|
|
535
|
+
const testDb = testClient.db('admin');
|
|
511
536
|
await testDb.admin().ping();
|
|
512
537
|
// Test basic operation (list collections)
|
|
513
538
|
try {
|
|
@@ -627,9 +652,8 @@ class SimpleMongoHelper {
|
|
|
627
652
|
try {
|
|
628
653
|
this.client = new mongodb_1.MongoClient(this.connectionString);
|
|
629
654
|
await this.client.connect();
|
|
630
|
-
//
|
|
631
|
-
|
|
632
|
-
this.db = this.client.db(dbName);
|
|
655
|
+
// Default to 'admin' database for initial connection (not used for operations)
|
|
656
|
+
this.db = this.client.db('admin');
|
|
633
657
|
this.isInitialized = true;
|
|
634
658
|
return;
|
|
635
659
|
}
|
|
@@ -655,10 +679,11 @@ class SimpleMongoHelper {
|
|
|
655
679
|
* @returns Array of documents matching the query or paginated result
|
|
656
680
|
* @throws Error if not initialized or if query fails
|
|
657
681
|
*/
|
|
658
|
-
async loadCollection(collectionName, query, options) {
|
|
682
|
+
async loadCollection(collectionName, query, options, database, ref, type) {
|
|
659
683
|
this.ensureInitialized();
|
|
660
684
|
try {
|
|
661
|
-
const
|
|
685
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
686
|
+
const collection = db.collection(collectionName);
|
|
662
687
|
const filter = query || {};
|
|
663
688
|
let cursor = collection.find(filter);
|
|
664
689
|
// Apply sorting if provided
|
|
@@ -701,10 +726,11 @@ class SimpleMongoHelper {
|
|
|
701
726
|
* @returns Single document matching the query or null
|
|
702
727
|
* @throws Error if not initialized or if query fails
|
|
703
728
|
*/
|
|
704
|
-
async findOne(collectionName, query, options) {
|
|
729
|
+
async findOne(collectionName, query, options, database, ref, type) {
|
|
705
730
|
this.ensureInitialized();
|
|
706
731
|
try {
|
|
707
|
-
const
|
|
732
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
733
|
+
const collection = db.collection(collectionName);
|
|
708
734
|
let findOptions = {};
|
|
709
735
|
if (options?.sort) {
|
|
710
736
|
findOptions.sort = options.sort;
|
|
@@ -727,10 +753,11 @@ class SimpleMongoHelper {
|
|
|
727
753
|
* @returns Insert result(s)
|
|
728
754
|
* @throws Error if not initialized or if insert fails
|
|
729
755
|
*/
|
|
730
|
-
async insert(collectionName, data, options) {
|
|
756
|
+
async insert(collectionName, data, options, database, ref, type) {
|
|
731
757
|
this.ensureInitialized();
|
|
732
758
|
try {
|
|
733
|
-
const
|
|
759
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
760
|
+
const collection = db.collection(collectionName);
|
|
734
761
|
const insertOptions = options?.session ? { session: options.session } : {};
|
|
735
762
|
if (Array.isArray(data)) {
|
|
736
763
|
const result = await collection.insertMany(data, insertOptions);
|
|
@@ -754,10 +781,11 @@ class SimpleMongoHelper {
|
|
|
754
781
|
* @returns Update result
|
|
755
782
|
* @throws Error if not initialized or if update fails
|
|
756
783
|
*/
|
|
757
|
-
async update(collectionName, filter, updateData, options) {
|
|
784
|
+
async update(collectionName, filter, updateData, options, database, ref, type) {
|
|
758
785
|
this.ensureInitialized();
|
|
759
786
|
try {
|
|
760
|
-
const
|
|
787
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
788
|
+
const collection = db.collection(collectionName);
|
|
761
789
|
const updateOptions = {};
|
|
762
790
|
if (options?.upsert !== undefined)
|
|
763
791
|
updateOptions.upsert = options.upsert;
|
|
@@ -784,10 +812,11 @@ class SimpleMongoHelper {
|
|
|
784
812
|
* @returns Delete result
|
|
785
813
|
* @throws Error if not initialized or if delete fails
|
|
786
814
|
*/
|
|
787
|
-
async delete(collectionName, filter, options) {
|
|
815
|
+
async delete(collectionName, filter, options, database, ref, type) {
|
|
788
816
|
this.ensureInitialized();
|
|
789
817
|
try {
|
|
790
|
-
const
|
|
818
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
819
|
+
const collection = db.collection(collectionName);
|
|
791
820
|
if (options?.multi) {
|
|
792
821
|
const result = await collection.deleteMany(filter);
|
|
793
822
|
return result;
|
|
@@ -808,10 +837,11 @@ class SimpleMongoHelper {
|
|
|
808
837
|
* @returns Number of documents matching the query
|
|
809
838
|
* @throws Error if not initialized or if count fails
|
|
810
839
|
*/
|
|
811
|
-
async countDocuments(collectionName, query) {
|
|
840
|
+
async countDocuments(collectionName, query, database, ref, type) {
|
|
812
841
|
this.ensureInitialized();
|
|
813
842
|
try {
|
|
814
|
-
const
|
|
843
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
844
|
+
const collection = db.collection(collectionName);
|
|
815
845
|
const count = await collection.countDocuments(query || {});
|
|
816
846
|
return count;
|
|
817
847
|
}
|
|
@@ -825,10 +855,11 @@ class SimpleMongoHelper {
|
|
|
825
855
|
* @returns Estimated number of documents
|
|
826
856
|
* @throws Error if not initialized or if count fails
|
|
827
857
|
*/
|
|
828
|
-
async estimatedDocumentCount(collectionName) {
|
|
858
|
+
async estimatedDocumentCount(collectionName, database, ref, type) {
|
|
829
859
|
this.ensureInitialized();
|
|
830
860
|
try {
|
|
831
|
-
const
|
|
861
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
862
|
+
const collection = db.collection(collectionName);
|
|
832
863
|
const count = await collection.estimatedDocumentCount();
|
|
833
864
|
return count;
|
|
834
865
|
}
|
|
@@ -843,10 +874,11 @@ class SimpleMongoHelper {
|
|
|
843
874
|
* @returns Array of aggregated results
|
|
844
875
|
* @throws Error if not initialized or if aggregation fails
|
|
845
876
|
*/
|
|
846
|
-
async aggregate(collectionName, pipeline) {
|
|
877
|
+
async aggregate(collectionName, pipeline, database, ref, type) {
|
|
847
878
|
this.ensureInitialized();
|
|
848
879
|
try {
|
|
849
|
-
const
|
|
880
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
881
|
+
const collection = db.collection(collectionName);
|
|
850
882
|
const results = await collection.aggregate(pipeline).toArray();
|
|
851
883
|
return results;
|
|
852
884
|
}
|
|
@@ -862,10 +894,11 @@ class SimpleMongoHelper {
|
|
|
862
894
|
* @returns Index name
|
|
863
895
|
* @throws Error if not initialized or if index creation fails
|
|
864
896
|
*/
|
|
865
|
-
async createIndex(collectionName, indexSpec, options) {
|
|
897
|
+
async createIndex(collectionName, indexSpec, options, database, ref, type) {
|
|
866
898
|
this.ensureInitialized();
|
|
867
899
|
try {
|
|
868
|
-
const
|
|
900
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
901
|
+
const collection = db.collection(collectionName);
|
|
869
902
|
const indexName = await collection.createIndex(indexSpec, options);
|
|
870
903
|
return indexName;
|
|
871
904
|
}
|
|
@@ -880,10 +913,11 @@ class SimpleMongoHelper {
|
|
|
880
913
|
* @returns Result object
|
|
881
914
|
* @throws Error if not initialized or if index drop fails
|
|
882
915
|
*/
|
|
883
|
-
async dropIndex(collectionName, indexName) {
|
|
916
|
+
async dropIndex(collectionName, indexName, database, ref, type) {
|
|
884
917
|
this.ensureInitialized();
|
|
885
918
|
try {
|
|
886
|
-
const
|
|
919
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
920
|
+
const collection = db.collection(collectionName);
|
|
887
921
|
const result = await collection.dropIndex(indexName);
|
|
888
922
|
return result;
|
|
889
923
|
}
|
|
@@ -897,10 +931,11 @@ class SimpleMongoHelper {
|
|
|
897
931
|
* @returns Array of index information
|
|
898
932
|
* @throws Error if not initialized or if listing fails
|
|
899
933
|
*/
|
|
900
|
-
async listIndexes(collectionName) {
|
|
934
|
+
async listIndexes(collectionName, database, ref, type) {
|
|
901
935
|
this.ensureInitialized();
|
|
902
936
|
try {
|
|
903
|
-
const
|
|
937
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
938
|
+
const collection = db.collection(collectionName);
|
|
904
939
|
const indexes = await collection.indexes();
|
|
905
940
|
return indexes;
|
|
906
941
|
}
|
|
@@ -962,9 +997,13 @@ class SimpleMongoHelper {
|
|
|
962
997
|
if (!inputConfig) {
|
|
963
998
|
throw new Error(`Ref '${ref}' not found in configuration inputs.`);
|
|
964
999
|
}
|
|
1000
|
+
const database = options?.database;
|
|
1001
|
+
const dbRef = options?.ref;
|
|
1002
|
+
const dbType = options?.type;
|
|
1003
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref: dbRef, type: dbType }));
|
|
965
1004
|
// Note: loadCollection doesn't support session yet, but we'll pass it through options
|
|
966
1005
|
// For now, we'll use the collection directly with session support
|
|
967
|
-
const collection =
|
|
1006
|
+
const collection = db.collection(inputConfig.collection);
|
|
968
1007
|
const filter = inputConfig.query || {};
|
|
969
1008
|
const session = options?.session;
|
|
970
1009
|
try {
|
|
@@ -1019,8 +1058,12 @@ class SimpleMongoHelper {
|
|
|
1019
1058
|
this.ensureInitialized();
|
|
1020
1059
|
const fieldName = options?.fieldName || '_sig';
|
|
1021
1060
|
const unique = options?.unique !== false; // Default to true
|
|
1061
|
+
const database = options?.database;
|
|
1062
|
+
const ref = options?.ref;
|
|
1063
|
+
const type = options?.type;
|
|
1022
1064
|
try {
|
|
1023
|
-
const
|
|
1065
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
1066
|
+
const collection = db.collection(collectionName);
|
|
1024
1067
|
const indexes = await collection.indexes();
|
|
1025
1068
|
// Find existing index on the signature field
|
|
1026
1069
|
const existingIndex = indexes.find(idx => {
|
|
@@ -1090,6 +1133,9 @@ class SimpleMongoHelper {
|
|
|
1090
1133
|
const mode = outputConfig.mode || this.config.output?.mode || 'append';
|
|
1091
1134
|
const ensureIndex = options?.ensureIndex !== false; // Default to true
|
|
1092
1135
|
const session = options?.session;
|
|
1136
|
+
const database = options?.database;
|
|
1137
|
+
const dbRef = options?.ref;
|
|
1138
|
+
const dbType = options?.type;
|
|
1093
1139
|
const result = {
|
|
1094
1140
|
inserted: 0,
|
|
1095
1141
|
updated: 0,
|
|
@@ -1097,7 +1143,8 @@ class SimpleMongoHelper {
|
|
|
1097
1143
|
indexCreated: false,
|
|
1098
1144
|
};
|
|
1099
1145
|
try {
|
|
1100
|
-
const
|
|
1146
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref: dbRef, type: dbType }));
|
|
1147
|
+
const collection = db.collection(collectionName);
|
|
1101
1148
|
// Handle replace mode: clear collection first
|
|
1102
1149
|
if (mode === 'replace') {
|
|
1103
1150
|
const deleteOptions = session ? { session } : {};
|
|
@@ -1251,6 +1298,9 @@ class SimpleMongoHelper {
|
|
|
1251
1298
|
const writeResult = await this.writeByRef(ref, documents, {
|
|
1252
1299
|
session: options?.session,
|
|
1253
1300
|
ensureIndex: options?.ensureIndex,
|
|
1301
|
+
database: options?.database,
|
|
1302
|
+
ref: options?.ref,
|
|
1303
|
+
type: options?.type,
|
|
1254
1304
|
});
|
|
1255
1305
|
const result = {
|
|
1256
1306
|
...writeResult,
|
|
@@ -1265,7 +1315,7 @@ class SimpleMongoHelper {
|
|
|
1265
1315
|
name: options.complete.name,
|
|
1266
1316
|
provider: options.complete.provider,
|
|
1267
1317
|
metadata: options.complete.metadata,
|
|
1268
|
-
}, { session: options.session });
|
|
1318
|
+
}, { session: options.session, database: options?.database, ref: options?.ref, type: options?.type });
|
|
1269
1319
|
result.completed = true;
|
|
1270
1320
|
}
|
|
1271
1321
|
catch (error) {
|
|
@@ -1286,7 +1336,7 @@ class SimpleMongoHelper {
|
|
|
1286
1336
|
*/
|
|
1287
1337
|
async mergeCollections(options) {
|
|
1288
1338
|
this.ensureInitialized();
|
|
1289
|
-
const { sourceCollection1, sourceCollection2, targetCollection, strategy, key, compositeKeys, joinType, fieldPrefix1 = 'record', fieldPrefix2 = 'assessment', includeIndex = strategy === 'index', onUnmatched1 = 'include', onUnmatched2 = 'include', session, } = options;
|
|
1339
|
+
const { sourceCollection1, sourceCollection2, targetCollection, strategy, key, compositeKeys, joinType, fieldPrefix1 = 'record', fieldPrefix2 = 'assessment', includeIndex = strategy === 'index', onUnmatched1 = 'include', onUnmatched2 = 'include', session, database, ref, type, } = options;
|
|
1290
1340
|
// Determine join behavior from joinType or fallback to onUnmatched flags
|
|
1291
1341
|
let includeUnmatched1;
|
|
1292
1342
|
let includeUnmatched2;
|
|
@@ -1326,9 +1376,10 @@ class SimpleMongoHelper {
|
|
|
1326
1376
|
errors: [],
|
|
1327
1377
|
};
|
|
1328
1378
|
try {
|
|
1329
|
-
const
|
|
1330
|
-
const
|
|
1331
|
-
const
|
|
1379
|
+
const db = this.getDatabase(this.resolveDatabase({ database, ref, type }));
|
|
1380
|
+
const coll1 = db.collection(sourceCollection1);
|
|
1381
|
+
const coll2 = db.collection(sourceCollection2);
|
|
1382
|
+
const targetColl = db.collection(targetCollection);
|
|
1332
1383
|
const findOptions = {};
|
|
1333
1384
|
if (session) {
|
|
1334
1385
|
findOptions.session = session;
|
|
@@ -1724,21 +1775,110 @@ class SimpleMongoHelper {
|
|
|
1724
1775
|
return this.db;
|
|
1725
1776
|
}
|
|
1726
1777
|
/**
|
|
1727
|
-
*
|
|
1728
|
-
* @param connectionString - MongoDB connection string
|
|
1729
|
-
* @returns
|
|
1778
|
+
* Strips database name from MongoDB connection string, returning base connection string.
|
|
1779
|
+
* @param connectionString - MongoDB connection string (may include database name)
|
|
1780
|
+
* @returns Base connection string without database name
|
|
1781
|
+
* @example
|
|
1782
|
+
* stripDatabaseFromConnectionString('mongodb://localhost:27017/admin')
|
|
1783
|
+
* // Returns: 'mongodb://localhost:27017/'
|
|
1730
1784
|
*/
|
|
1731
|
-
|
|
1785
|
+
stripDatabaseFromConnectionString(connectionString) {
|
|
1732
1786
|
try {
|
|
1733
1787
|
const url = new URL(connectionString);
|
|
1734
|
-
|
|
1735
|
-
|
|
1788
|
+
// Remove pathname (database name) but keep trailing slash
|
|
1789
|
+
url.pathname = '/';
|
|
1790
|
+
return url.toString();
|
|
1736
1791
|
}
|
|
1737
1792
|
catch {
|
|
1738
|
-
// If URL parsing fails, try
|
|
1739
|
-
|
|
1740
|
-
|
|
1793
|
+
// If URL parsing fails, try regex pattern matching
|
|
1794
|
+
// Match: mongodb://host:port/database?options or mongodb://host:port/database
|
|
1795
|
+
const match = connectionString.match(/^([^\/]+\/\/[^\/]+)\/([^\/\?]+)(\?.*)?$/);
|
|
1796
|
+
if (match) {
|
|
1797
|
+
// Return base URL with trailing slash
|
|
1798
|
+
return match[1] + '/';
|
|
1799
|
+
}
|
|
1800
|
+
// If no database found, return as-is (should already be base URL)
|
|
1801
|
+
return connectionString.endsWith('/') ? connectionString : connectionString + '/';
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Resolves the database name from provided options using the databases config map.
|
|
1806
|
+
* Priority: database > ref+type > ref > type
|
|
1807
|
+
* @param options - Options containing database, ref, and/or type
|
|
1808
|
+
* @returns Resolved database name or undefined (will default to 'admin')
|
|
1809
|
+
* @throws Error if no match found or multiple matches found
|
|
1810
|
+
* @internal
|
|
1811
|
+
*/
|
|
1812
|
+
resolveDatabase(options) {
|
|
1813
|
+
// Priority 1: If database is provided directly, use it
|
|
1814
|
+
if (options?.database) {
|
|
1815
|
+
return options.database;
|
|
1816
|
+
}
|
|
1817
|
+
// If no config or no databases map, return undefined (will default to 'admin')
|
|
1818
|
+
if (!this.config || !this.config.databases || this.config.databases.length === 0) {
|
|
1819
|
+
return undefined;
|
|
1820
|
+
}
|
|
1821
|
+
const databases = this.config.databases;
|
|
1822
|
+
// Priority 2: If both ref and type are provided, find exact match
|
|
1823
|
+
if (options?.ref && options?.type) {
|
|
1824
|
+
const matches = databases.filter(db => db.ref === options.ref && db.type === options.type);
|
|
1825
|
+
if (matches.length === 0) {
|
|
1826
|
+
throw new Error(`No database found for ref: ${options.ref} and type: ${options.type}`);
|
|
1827
|
+
}
|
|
1828
|
+
if (matches.length > 1) {
|
|
1829
|
+
throw new Error(`Multiple databases found for ref: ${options.ref} and type: ${options.type}`);
|
|
1830
|
+
}
|
|
1831
|
+
return matches[0].database;
|
|
1832
|
+
}
|
|
1833
|
+
// Priority 3: If ref is provided, find by ref
|
|
1834
|
+
if (options?.ref) {
|
|
1835
|
+
const matches = databases.filter(db => db.ref === options.ref);
|
|
1836
|
+
if (matches.length === 0) {
|
|
1837
|
+
throw new Error(`No database found for ref: ${options.ref}`);
|
|
1838
|
+
}
|
|
1839
|
+
if (matches.length > 1) {
|
|
1840
|
+
throw new Error(`Multiple databases found for ref: ${options.ref}. Use 'type' parameter to narrow down.`);
|
|
1841
|
+
}
|
|
1842
|
+
return matches[0].database;
|
|
1741
1843
|
}
|
|
1844
|
+
// Priority 4: If type is provided, find by type
|
|
1845
|
+
if (options?.type) {
|
|
1846
|
+
const matches = databases.filter(db => db.type === options.type);
|
|
1847
|
+
if (matches.length === 0) {
|
|
1848
|
+
throw new Error(`No database found for type: ${options.type}`);
|
|
1849
|
+
}
|
|
1850
|
+
if (matches.length > 1) {
|
|
1851
|
+
throw new Error(`Multiple databases found for type: ${options.type}. Use 'ref' parameter to narrow down.`);
|
|
1852
|
+
}
|
|
1853
|
+
return matches[0].database;
|
|
1854
|
+
}
|
|
1855
|
+
// No options provided, return undefined (will default to 'admin')
|
|
1856
|
+
return undefined;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Gets a database instance by name. Defaults to 'admin' if no name provided.
|
|
1860
|
+
* @param databaseName - Optional database name (defaults to 'admin')
|
|
1861
|
+
* @returns Database instance
|
|
1862
|
+
* @throws Error if client is not initialized
|
|
1863
|
+
* @internal
|
|
1864
|
+
*/
|
|
1865
|
+
getDatabase(databaseName) {
|
|
1866
|
+
if (!this.client) {
|
|
1867
|
+
throw new Error('MongoDB client not initialized. Call initialize() first.');
|
|
1868
|
+
}
|
|
1869
|
+
return this.client.db(databaseName || 'admin');
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Gets a database instance by name. Defaults to 'admin' if no name provided.
|
|
1873
|
+
* Public method for use by ProgressAPIImpl.
|
|
1874
|
+
* @param databaseName - Optional database name (defaults to 'admin')
|
|
1875
|
+
* @param ref - Optional ref for database resolution
|
|
1876
|
+
* @param type - Optional type for database resolution
|
|
1877
|
+
* @returns Database instance
|
|
1878
|
+
* @throws Error if client is not initialized
|
|
1879
|
+
*/
|
|
1880
|
+
getDatabaseByName(databaseName, ref, type) {
|
|
1881
|
+
return this.getDatabase(this.resolveDatabase({ database: databaseName, ref, type }));
|
|
1742
1882
|
}
|
|
1743
1883
|
}
|
|
1744
1884
|
exports.SimpleMongoHelper = SimpleMongoHelper;
|