@resolveio/server-lib 12.6.6 → 12.6.8
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/managers/mongo.manager.d.ts +2 -0
- package/managers/mongo.manager.js +91 -70
- package/managers/mongo.manager.js.map +1 -1
- package/package.json +2 -1
- package/server-app.js +4 -0
- package/server-app.js.map +1 -1
|
@@ -123,6 +123,8 @@ export declare class MongoManagerCollection<T extends CollectionDocument> {
|
|
|
123
123
|
createLogs: boolean;
|
|
124
124
|
useRB: boolean;
|
|
125
125
|
collectionOptions: CreateCollectionOptions;
|
|
126
|
+
private static indexQueue;
|
|
127
|
+
static indexQueueDrain: () => void;
|
|
126
128
|
constructor(options: MongoManagerCollectionOptions);
|
|
127
129
|
aggregate(pipeline: object[], options?: AggregateOptions, skipCache?: boolean): Promise<any[]>;
|
|
128
130
|
aggregateCount(pipeline: object[], options?: AggregateOptions): Promise<number>;
|
|
@@ -74,6 +74,7 @@ var monitor_manager_1 = require("./monitor.manager");
|
|
|
74
74
|
var os_1 = require("os");
|
|
75
75
|
var numCPUs = (0, os_1.cpus)().length;
|
|
76
76
|
var v8 = require('v8');
|
|
77
|
+
var async_1 = require("async");
|
|
77
78
|
var MongoManager = /** @class */ (function () {
|
|
78
79
|
function MongoManager() {
|
|
79
80
|
var _this = this;
|
|
@@ -439,6 +440,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
439
440
|
clearInterval(interval);
|
|
440
441
|
}
|
|
441
442
|
}, 1);
|
|
443
|
+
MongoManagerCollection.indexQueue.drain = MongoManagerCollection.indexQueueDrain;
|
|
442
444
|
}
|
|
443
445
|
MongoManagerCollection.prototype.aggregate = function (pipeline, options, skipCache) {
|
|
444
446
|
var _this = this;
|
|
@@ -582,33 +584,33 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
582
584
|
MongoManagerCollection.prototype.createIndex = function (fieldOrSpec, options) {
|
|
583
585
|
var _this = this;
|
|
584
586
|
return new Promise(function (resolve, reject) {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
console.log(new Date(), 'Error Setting Up Index for Collection', _this.collectionName, fieldOrSpec, options, err);
|
|
587
|
+
MongoManagerCollection.indexQueue.push({
|
|
588
|
+
action: 'createIndex',
|
|
589
|
+
collection: _this,
|
|
590
|
+
specs: [fieldOrSpec],
|
|
591
|
+
options: options
|
|
592
|
+
}, function (err, result) {
|
|
593
|
+
if (err)
|
|
593
594
|
reject(err);
|
|
594
|
-
|
|
595
|
-
|
|
595
|
+
else
|
|
596
|
+
resolve(result);
|
|
597
|
+
});
|
|
596
598
|
});
|
|
597
599
|
};
|
|
598
600
|
MongoManagerCollection.prototype.createIndexes = function (indexSpecs, options) {
|
|
599
601
|
var _this = this;
|
|
600
602
|
return new Promise(function (resolve, reject) {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
console.log(new Date(), 'Error Setting Up Indexes for Collection', _this.collectionName, indexSpecs, options, err);
|
|
603
|
+
MongoManagerCollection.indexQueue.push({
|
|
604
|
+
action: 'createIndexes',
|
|
605
|
+
collection: _this,
|
|
606
|
+
specs: [indexSpecs],
|
|
607
|
+
options: options
|
|
608
|
+
}, function (err, result) {
|
|
609
|
+
if (err)
|
|
609
610
|
reject(err);
|
|
610
|
-
|
|
611
|
-
|
|
611
|
+
else
|
|
612
|
+
resolve(result);
|
|
613
|
+
});
|
|
612
614
|
});
|
|
613
615
|
};
|
|
614
616
|
MongoManagerCollection.prototype.deleteMany = function (filter, options, bypassLogs) {
|
|
@@ -673,15 +675,15 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
673
675
|
if (filter === void 0) { filter = {}; }
|
|
674
676
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
675
677
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
676
|
-
var
|
|
678
|
+
var monitor_3, monitor_4;
|
|
677
679
|
var _this = this;
|
|
678
680
|
return __generator(this, function (_a) {
|
|
679
681
|
if (this.createLogs && !bypassLogs) {
|
|
680
|
-
|
|
682
|
+
monitor_3 = new monitor_manager_1.MonitorMongo('findOneAndDelete', this.collectionName, JSON.stringify([filter, options]));
|
|
681
683
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).findOneAndDelete(filter, options).then(function (returnVal) { return __awaiter(_this, void 0, void 0, function () {
|
|
682
684
|
var doc, versionDoc;
|
|
683
685
|
return __generator(this, function (_a) {
|
|
684
|
-
|
|
686
|
+
monitor_3.finish();
|
|
685
687
|
doc = returnVal.value;
|
|
686
688
|
if (doc) {
|
|
687
689
|
if (this.createLogs && !bypassLogs) {
|
|
@@ -713,15 +715,15 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
713
715
|
return [2 /*return*/];
|
|
714
716
|
});
|
|
715
717
|
}); }, function (err) {
|
|
716
|
-
|
|
718
|
+
monitor_3.finish();
|
|
717
719
|
console.log(new Date(), 'Error Find One And Delete', _this.collectionName, filter, options, err);
|
|
718
720
|
reject(err);
|
|
719
721
|
});
|
|
720
722
|
}
|
|
721
723
|
else {
|
|
722
|
-
|
|
724
|
+
monitor_4 = new monitor_manager_1.MonitorMongo('deleteOne', this.collectionName, JSON.stringify([filter, options]));
|
|
723
725
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).deleteOne(filter, options).then(function (res) {
|
|
724
|
-
|
|
726
|
+
monitor_4.finish();
|
|
725
727
|
if (res.acknowledged) {
|
|
726
728
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
727
729
|
resolve(res.deletedCount);
|
|
@@ -730,7 +732,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
730
732
|
reject(res.acknowledged);
|
|
731
733
|
}
|
|
732
734
|
}, function (err) {
|
|
733
|
-
|
|
735
|
+
monitor_4.finish();
|
|
734
736
|
console.log(new Date(), 'Error Delete One', _this.collectionName, filter, options, err);
|
|
735
737
|
reject(err);
|
|
736
738
|
});
|
|
@@ -800,7 +802,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
800
802
|
if (filter === void 0) { filter = {}; }
|
|
801
803
|
if (skipCache === void 0) { skipCache = false; }
|
|
802
804
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
803
|
-
var
|
|
805
|
+
var monitor_5;
|
|
804
806
|
var _this = this;
|
|
805
807
|
return __generator(this, function (_a) {
|
|
806
808
|
if (!skipCache) {
|
|
@@ -828,12 +830,12 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
828
830
|
});
|
|
829
831
|
}
|
|
830
832
|
else {
|
|
831
|
-
|
|
833
|
+
monitor_5 = new monitor_manager_1.MonitorMongo('find', this.collectionName, JSON.stringify([filter, options]));
|
|
832
834
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).find(filter, options).toArray().then(function (res) {
|
|
833
|
-
|
|
835
|
+
monitor_5.finish();
|
|
834
836
|
resolve(res);
|
|
835
837
|
}, function (err) {
|
|
836
|
-
|
|
838
|
+
monitor_5.finish();
|
|
837
839
|
console.log(new Date(), 'Error Find', _this.collectionName, filter, options, err);
|
|
838
840
|
reject(err);
|
|
839
841
|
});
|
|
@@ -921,12 +923,12 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
921
923
|
});
|
|
922
924
|
}
|
|
923
925
|
else {
|
|
924
|
-
var
|
|
926
|
+
var monitor_6 = new monitor_manager_1.MonitorMongo('findOne', _this.collectionName, JSON.stringify([filter, options]));
|
|
925
927
|
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName, _this.collectionOptions).findOne(filter, options).then(function (res) {
|
|
926
|
-
|
|
928
|
+
monitor_6.finish();
|
|
927
929
|
resolve(res);
|
|
928
930
|
}, function (err) {
|
|
929
|
-
|
|
931
|
+
monitor_6.finish();
|
|
930
932
|
console.log(new Date(), 'Error Find One', _this.collectionName, filter, options, err);
|
|
931
933
|
reject(err);
|
|
932
934
|
});
|
|
@@ -1177,7 +1179,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1177
1179
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
1178
1180
|
if (bypassMonitor === void 0) { bypassMonitor = false; }
|
|
1179
1181
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1180
|
-
var validationResults, validDocs, i, doc, date,
|
|
1182
|
+
var validationResults, validDocs, i, doc, date, monitor_7;
|
|
1181
1183
|
var _this = this;
|
|
1182
1184
|
return __generator(this, function (_a) {
|
|
1183
1185
|
if (!docs.length) {
|
|
@@ -1226,13 +1228,13 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1226
1228
|
}
|
|
1227
1229
|
}
|
|
1228
1230
|
if (validDocs.length) {
|
|
1229
|
-
|
|
1231
|
+
monitor_7 = null;
|
|
1230
1232
|
if (!bypassMonitor) {
|
|
1231
|
-
|
|
1233
|
+
monitor_7 = new monitor_manager_1.MonitorMongo('insertMany', this.collectionName, JSON.stringify([validDocs, options]));
|
|
1232
1234
|
}
|
|
1233
1235
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).insertMany(validDocs, options).then(function (res) {
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1236
|
+
if (monitor_7) {
|
|
1237
|
+
monitor_7.finish();
|
|
1236
1238
|
}
|
|
1237
1239
|
if (res.acknowledged) {
|
|
1238
1240
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
@@ -1242,8 +1244,8 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1242
1244
|
reject(res.acknowledged);
|
|
1243
1245
|
}
|
|
1244
1246
|
}, function (err) {
|
|
1245
|
-
if (
|
|
1246
|
-
|
|
1247
|
+
if (monitor_7) {
|
|
1248
|
+
monitor_7.finish();
|
|
1247
1249
|
}
|
|
1248
1250
|
console.log(new Date(), 'Error Insert Many', _this.collectionName, validDocs, options, err);
|
|
1249
1251
|
reject(err);
|
|
@@ -1344,7 +1346,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1344
1346
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
1345
1347
|
if (doc === void 0) { doc = null; }
|
|
1346
1348
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1347
|
-
var validation, isValid, date, versionDoc,
|
|
1349
|
+
var validation, isValid, date, versionDoc, monitor_8, prevDoc, docId, docVersion, updatedDoc_1, monitor_9, monitor_10, monitor_11, monitor_12;
|
|
1348
1350
|
var _this = this;
|
|
1349
1351
|
return __generator(this, function (_a) {
|
|
1350
1352
|
switch (_a.label) {
|
|
@@ -1396,9 +1398,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1396
1398
|
route: ''
|
|
1397
1399
|
});
|
|
1398
1400
|
}
|
|
1399
|
-
|
|
1401
|
+
monitor_8 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1400
1402
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).replaceOne(filter, replacement, options).then(function (res) {
|
|
1401
|
-
|
|
1403
|
+
monitor_8.finish();
|
|
1402
1404
|
if (res.acknowledged) {
|
|
1403
1405
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1404
1406
|
resolve(res.modifiedCount);
|
|
@@ -1407,7 +1409,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1407
1409
|
reject(res.acknowledged);
|
|
1408
1410
|
}
|
|
1409
1411
|
}, function (err) {
|
|
1410
|
-
|
|
1412
|
+
monitor_8.finish();
|
|
1411
1413
|
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, replacement, options, err);
|
|
1412
1414
|
reject(err);
|
|
1413
1415
|
});
|
|
@@ -1442,9 +1444,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1442
1444
|
route: ''
|
|
1443
1445
|
});
|
|
1444
1446
|
}
|
|
1445
|
-
|
|
1447
|
+
monitor_9 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, updatedDoc_1, options]));
|
|
1446
1448
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).replaceOne(filter, updatedDoc_1, options).then(function (res) {
|
|
1447
|
-
|
|
1449
|
+
monitor_9.finish();
|
|
1448
1450
|
if (res.acknowledged) {
|
|
1449
1451
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1450
1452
|
resolve(res.modifiedCount);
|
|
@@ -1453,7 +1455,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1453
1455
|
reject(res.acknowledged);
|
|
1454
1456
|
}
|
|
1455
1457
|
}, function (err) {
|
|
1456
|
-
|
|
1458
|
+
monitor_9.finish();
|
|
1457
1459
|
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, updatedDoc_1, options, err);
|
|
1458
1460
|
reject(err);
|
|
1459
1461
|
});
|
|
@@ -1486,9 +1488,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1486
1488
|
route: ''
|
|
1487
1489
|
});
|
|
1488
1490
|
}
|
|
1489
|
-
|
|
1491
|
+
monitor_10 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1490
1492
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).replaceOne(filter, replacement, options).then(function (res) {
|
|
1491
|
-
|
|
1493
|
+
monitor_10.finish();
|
|
1492
1494
|
if (res.acknowledged) {
|
|
1493
1495
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1494
1496
|
resolve(res.modifiedCount);
|
|
@@ -1497,7 +1499,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1497
1499
|
reject(res.acknowledged);
|
|
1498
1500
|
}
|
|
1499
1501
|
}, function (err) {
|
|
1500
|
-
|
|
1502
|
+
monitor_10.finish();
|
|
1501
1503
|
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, replacement, options, err);
|
|
1502
1504
|
reject(err);
|
|
1503
1505
|
});
|
|
@@ -1524,9 +1526,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1524
1526
|
else {
|
|
1525
1527
|
options.returnDocument = 'before';
|
|
1526
1528
|
}
|
|
1527
|
-
|
|
1529
|
+
monitor_11 = new monitor_manager_1.MonitorMongo('findOneAndReplace', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1528
1530
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).findOneAndReplace(filter, replacement, options).then(function (res) {
|
|
1529
|
-
|
|
1531
|
+
monitor_11.finish();
|
|
1530
1532
|
var doc = res.value;
|
|
1531
1533
|
if (doc) {
|
|
1532
1534
|
log_collection_1.Logs.insertOne({
|
|
@@ -1559,15 +1561,15 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1559
1561
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1560
1562
|
resolve(res.ok);
|
|
1561
1563
|
}, function (err) {
|
|
1562
|
-
|
|
1564
|
+
monitor_11.finish();
|
|
1563
1565
|
console.log(new Date(), 'Error Find One And Replace', _this.collectionName, filter, replacement, options, err);
|
|
1564
1566
|
reject(err);
|
|
1565
1567
|
});
|
|
1566
1568
|
}
|
|
1567
1569
|
else {
|
|
1568
|
-
|
|
1570
|
+
monitor_12 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1569
1571
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).replaceOne(filter, replacement, options).then(function (res) {
|
|
1570
|
-
|
|
1572
|
+
monitor_12.finish();
|
|
1571
1573
|
if (res.acknowledged) {
|
|
1572
1574
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1573
1575
|
resolve(res.modifiedCount);
|
|
@@ -1576,7 +1578,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1576
1578
|
reject(res.acknowledged);
|
|
1577
1579
|
}
|
|
1578
1580
|
}, function (err) {
|
|
1579
|
-
|
|
1581
|
+
monitor_12.finish();
|
|
1580
1582
|
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, replacement, options, err);
|
|
1581
1583
|
reject(err);
|
|
1582
1584
|
});
|
|
@@ -1699,7 +1701,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1699
1701
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1700
1702
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
1701
1703
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1702
|
-
var validation, isValid, date, doc, versionDoc,
|
|
1704
|
+
var validation, isValid, date, doc, versionDoc, monitor_13, monitor_14, monitor_15, monitor_16;
|
|
1703
1705
|
var _this = this;
|
|
1704
1706
|
return __generator(this, function (_a) {
|
|
1705
1707
|
switch (_a.label) {
|
|
@@ -1760,9 +1762,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1760
1762
|
update.$inc.__v = 1;
|
|
1761
1763
|
}
|
|
1762
1764
|
}
|
|
1763
|
-
|
|
1765
|
+
monitor_13 = new monitor_manager_1.MonitorMongo('updateOne', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1764
1766
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).updateOne(filter, update, options).then(function (res) {
|
|
1765
|
-
|
|
1767
|
+
monitor_13.finish();
|
|
1766
1768
|
if (res.acknowledged) {
|
|
1767
1769
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1768
1770
|
resolve(res.modifiedCount);
|
|
@@ -1771,7 +1773,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1771
1773
|
reject(res.acknowledged);
|
|
1772
1774
|
}
|
|
1773
1775
|
}, function (err) {
|
|
1774
|
-
|
|
1776
|
+
monitor_13.finish();
|
|
1775
1777
|
console.log(new Date(), 'Error Update One', _this.collectionName, filter, update, options, err);
|
|
1776
1778
|
reject(err);
|
|
1777
1779
|
});
|
|
@@ -1814,9 +1816,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1814
1816
|
route: ''
|
|
1815
1817
|
});
|
|
1816
1818
|
}
|
|
1817
|
-
|
|
1819
|
+
monitor_14 = new monitor_manager_1.MonitorMongo('updateOne', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1818
1820
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).updateOne(filter, update, options).then(function (res) {
|
|
1819
|
-
|
|
1821
|
+
monitor_14.finish();
|
|
1820
1822
|
if (res.acknowledged) {
|
|
1821
1823
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1822
1824
|
resolve(res.modifiedCount);
|
|
@@ -1825,7 +1827,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1825
1827
|
reject(res.acknowledged);
|
|
1826
1828
|
}
|
|
1827
1829
|
}, function (err) {
|
|
1828
|
-
|
|
1830
|
+
monitor_14.finish();
|
|
1829
1831
|
console.log(new Date(), 'Error Update One', _this.collectionName, filter, update, options, err);
|
|
1830
1832
|
reject(err);
|
|
1831
1833
|
});
|
|
@@ -1865,9 +1867,9 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1865
1867
|
else {
|
|
1866
1868
|
options.returnDocument = 'before';
|
|
1867
1869
|
}
|
|
1868
|
-
|
|
1870
|
+
monitor_15 = new monitor_manager_1.MonitorMongo('findOneAndUpdate', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1869
1871
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).findOneAndUpdate(filter, update, options).then(function (res) {
|
|
1870
|
-
|
|
1872
|
+
monitor_15.finish();
|
|
1871
1873
|
var doc = res.value;
|
|
1872
1874
|
if (doc) {
|
|
1873
1875
|
log_collection_1.Logs.insertOne({
|
|
@@ -1904,15 +1906,15 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1904
1906
|
resolve(0);
|
|
1905
1907
|
}
|
|
1906
1908
|
}, function (err) {
|
|
1907
|
-
|
|
1909
|
+
monitor_15.finish();
|
|
1908
1910
|
console.log(new Date(), 'Error Find One And Update', _this.collectionName, filter, update, options, err);
|
|
1909
1911
|
reject(err);
|
|
1910
1912
|
});
|
|
1911
1913
|
}
|
|
1912
1914
|
else {
|
|
1913
|
-
|
|
1915
|
+
monitor_16 = new monitor_manager_1.MonitorMongo('updateOne', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1914
1916
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).updateOne(filter, update, options).then(function (res) {
|
|
1915
|
-
|
|
1917
|
+
monitor_16.finish();
|
|
1916
1918
|
if (res.acknowledged) {
|
|
1917
1919
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1918
1920
|
resolve(res.modifiedCount);
|
|
@@ -1921,7 +1923,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1921
1923
|
reject(res.acknowledged);
|
|
1922
1924
|
}
|
|
1923
1925
|
}, function (err) {
|
|
1924
|
-
|
|
1926
|
+
monitor_16.finish();
|
|
1925
1927
|
console.log(new Date(), 'Error Update One', _this.collectionName, filter, update, options, err);
|
|
1926
1928
|
reject(err);
|
|
1927
1929
|
});
|
|
@@ -1952,6 +1954,25 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1952
1954
|
});
|
|
1953
1955
|
return stream;
|
|
1954
1956
|
};
|
|
1957
|
+
MongoManagerCollection.indexQueue = async_1.default.queue(function (task, callback) {
|
|
1958
|
+
var action = task.action, collection = task.collection, specs = task.specs, options = task.options;
|
|
1959
|
+
var dbCollection = index_1.ResolveIOServer.getMainDB().collection(collection.collectionName, collection.collectionOptions);
|
|
1960
|
+
if (!dbCollection) {
|
|
1961
|
+
return callback(new Error("Collection ".concat(collection.collectionName, " not found")));
|
|
1962
|
+
}
|
|
1963
|
+
var monitor = new monitor_manager_1.MonitorMongo(action, collection.collectionName, JSON.stringify([specs, options]));
|
|
1964
|
+
dbCollection[action].apply(dbCollection, __spreadArray(__spreadArray([], specs, false), [options], false)).then(function (res) {
|
|
1965
|
+
monitor.finish();
|
|
1966
|
+
callback(null, res);
|
|
1967
|
+
}).catch(function (err) {
|
|
1968
|
+
monitor.finish();
|
|
1969
|
+
console.log(new Date(), "Error Setting Up ".concat(action === 'createIndex' ? 'Index' : 'Indexes', " for Collection"), collection.collectionName, specs, options, err);
|
|
1970
|
+
callback(err);
|
|
1971
|
+
});
|
|
1972
|
+
}, 1);
|
|
1973
|
+
MongoManagerCollection.indexQueueDrain = function () {
|
|
1974
|
+
console.log('Done creating indexes');
|
|
1975
|
+
};
|
|
1955
1976
|
return MongoManagerCollection;
|
|
1956
1977
|
}());
|
|
1957
1978
|
exports.MongoManagerCollection = MongoManagerCollection;
|