@resolveio/server-lib 11.0.0 → 11.0.1
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-server-app.js +1 -10
- package/client-server-app.js.map +1 -1
- package/index.d.ts +1 -2
- package/index.js +2 -4
- package/index.js.map +1 -1
- package/managers/method.manager.js +0 -1
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.d.ts +12 -19
- package/managers/mongo.manager.js +347 -47
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.d.ts +20 -3
- package/managers/monitor.manager.js +128 -139
- package/managers/monitor.manager.js.map +1 -1
- package/package.json +7 -9
- package/server-app.d.ts +1 -1
- package/server-app.js +2 -4
- package/server-app.js.map +1 -1
|
@@ -48,6 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
52
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
53
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
54
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
55
|
+
r[k] = a[j];
|
|
56
|
+
return r;
|
|
57
|
+
};
|
|
51
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
59
|
exports.objectIdHexString = exports.UserCollection = exports.Collection = exports.Model = exports.MongoManager = void 0;
|
|
53
60
|
var simpl_schema_1 = require("simpl-schema");
|
|
@@ -59,6 +66,7 @@ var log_collection_1 = require("../collections/log.collection");
|
|
|
59
66
|
var NodeCache = require("node-cache");
|
|
60
67
|
var crypto = require('crypto');
|
|
61
68
|
var scmp = require('scmp');
|
|
69
|
+
var monitor_manager_1 = require("./monitor.manager");
|
|
62
70
|
var v8 = require('v8');
|
|
63
71
|
var MongoManager = /** @class */ (function () {
|
|
64
72
|
function MongoManager() {
|
|
@@ -133,7 +141,9 @@ var MongoManager = /** @class */ (function () {
|
|
|
133
141
|
}
|
|
134
142
|
else {
|
|
135
143
|
if (!mongoQueue.name_function_addt) {
|
|
144
|
+
var monitor_1 = new monitor_manager_1.MonitorMongo(mongoQueue.name_function, mongoQueue.name_collection, JSON.stringify(mongoQueue.data_function));
|
|
136
145
|
(_a = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_a, mongoQueue.data_function).then(function (res) {
|
|
146
|
+
monitor_1.finish();
|
|
137
147
|
if (!mongoQueue.invalidateFlag) {
|
|
138
148
|
mongoQueue.cacheId = _this._mongoQueueCacheId;
|
|
139
149
|
_this._mongoQueueCacheId += 1;
|
|
@@ -155,6 +165,8 @@ var MongoManager = /** @class */ (function () {
|
|
|
155
165
|
}
|
|
156
166
|
mongoQueue.running = false;
|
|
157
167
|
}, function (err) {
|
|
168
|
+
monitor_1.finish();
|
|
169
|
+
console.log.apply(console, __spreadArrays([new Date(), 'Error ' + mongoQueue.name_function, mongoQueue.name_collection], mongoQueue.data_function, [err]));
|
|
158
170
|
mongoQueue.cbs.forEach(function (cb) {
|
|
159
171
|
cb(err, null, false);
|
|
160
172
|
});
|
|
@@ -167,7 +179,9 @@ var MongoManager = /** @class */ (function () {
|
|
|
167
179
|
});
|
|
168
180
|
}
|
|
169
181
|
else {
|
|
182
|
+
var monitor_2 = new monitor_manager_1.MonitorMongo(mongoQueue.name_function, mongoQueue.name_collection, JSON.stringify(__spreadArrays(mongoQueue.data_function, [mongoQueue.name_function_addt], mongoQueue.data_function_addt)));
|
|
170
183
|
(_b = (_c = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_c, mongoQueue.data_function))[mongoQueue.name_function_addt].apply(_b, mongoQueue.data_function_addt).then(function (res) {
|
|
184
|
+
monitor_2.finish();
|
|
171
185
|
if (!mongoQueue.invalidateFlag) {
|
|
172
186
|
mongoQueue.cacheId = _this._mongoQueueCacheId;
|
|
173
187
|
_this._mongoQueueCacheId += 1;
|
|
@@ -189,6 +203,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
189
203
|
}
|
|
190
204
|
mongoQueue.running = false;
|
|
191
205
|
}, function (err) {
|
|
206
|
+
monitor_2.finish();
|
|
192
207
|
mongoQueue.cbs.forEach(function (cb) {
|
|
193
208
|
cb(err, null, false);
|
|
194
209
|
});
|
|
@@ -356,7 +371,15 @@ var Collection = /** @class */ (function () {
|
|
|
356
371
|
});
|
|
357
372
|
}
|
|
358
373
|
else {
|
|
359
|
-
|
|
374
|
+
var monitor_3 = new monitor_manager_1.MonitorMongo('aggregate', _this.collectionName, JSON.stringify([pipeline, options]));
|
|
375
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).aggregate(pipeline, options).toArray().then(function (res) {
|
|
376
|
+
monitor_3.finish();
|
|
377
|
+
resolve(res);
|
|
378
|
+
}, function (err) {
|
|
379
|
+
monitor_3.finish();
|
|
380
|
+
console.log(new Date(), 'Error Aggregate', _this.collectionName, pipeline, options, err);
|
|
381
|
+
reject(err);
|
|
382
|
+
});
|
|
360
383
|
}
|
|
361
384
|
});
|
|
362
385
|
};
|
|
@@ -389,15 +412,39 @@ var Collection = /** @class */ (function () {
|
|
|
389
412
|
});
|
|
390
413
|
};
|
|
391
414
|
Collection.prototype.aggregateCursor = function (pipeline, options) {
|
|
392
|
-
|
|
415
|
+
var monitor = new monitor_manager_1.MonitorMongo('aggregateCursor', this.collectionName, JSON.stringify([pipeline, options]));
|
|
416
|
+
var cursor = index_1.ResolveIOServer.getMainDB().collection(this.collectionName).aggregate(pipeline, options);
|
|
417
|
+
cursor.on('close', function (ev) {
|
|
418
|
+
monitor.finish();
|
|
419
|
+
return ev;
|
|
420
|
+
});
|
|
421
|
+
return cursor;
|
|
393
422
|
};
|
|
394
|
-
Collection.prototype.aggregateStream = function (pipeline, options) {
|
|
395
|
-
|
|
423
|
+
Collection.prototype.aggregateStream = function (pipeline, options, streamOptions) {
|
|
424
|
+
var monitor = new monitor_manager_1.MonitorMongo('aggregateStream', this.collectionName, JSON.stringify([pipeline, options, streamOptions]));
|
|
425
|
+
var stream = index_1.ResolveIOServer.getMainDB().collection(this.collectionName).aggregate(pipeline, options).stream(streamOptions);
|
|
426
|
+
stream.on('end', function (ev) {
|
|
427
|
+
monitor.finish();
|
|
428
|
+
return ev;
|
|
429
|
+
});
|
|
430
|
+
return stream;
|
|
396
431
|
};
|
|
397
432
|
Collection.prototype.countDocuments = function (filter, options) {
|
|
433
|
+
var _this = this;
|
|
398
434
|
if (filter === void 0) { filter = {}; }
|
|
399
|
-
return
|
|
435
|
+
return new Promise(function (resolve, reject) {
|
|
436
|
+
var monitor = new monitor_manager_1.MonitorMongo('countDocuments', _this.collectionName, JSON.stringify([filter, options]));
|
|
437
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).countDocuments(filter, options).then(function (res) {
|
|
438
|
+
monitor.finish();
|
|
439
|
+
resolve(res);
|
|
440
|
+
}, function (err) {
|
|
441
|
+
monitor.finish();
|
|
442
|
+
console.log(new Date(), 'Error Count Documents', _this.collectionName, filter, options, err);
|
|
443
|
+
reject(err);
|
|
444
|
+
});
|
|
445
|
+
});
|
|
400
446
|
};
|
|
447
|
+
//Helper Function (1 or Many) - Not Real Mongo Function
|
|
401
448
|
Collection.prototype.create = function (f_docs, options) {
|
|
402
449
|
var docs = [];
|
|
403
450
|
if (!Array.isArray(f_docs)) {
|
|
@@ -409,9 +456,12 @@ var Collection = /** @class */ (function () {
|
|
|
409
456
|
var _this = this;
|
|
410
457
|
return new Promise(function (resolve, reject) {
|
|
411
458
|
if (index_1.ResolveIOServer.getMainDB().collection(_this.collectionName)) {
|
|
459
|
+
var monitor_4 = new monitor_manager_1.MonitorMongo('createIndex', _this.collectionName, JSON.stringify([fieldOrSpec, options]));
|
|
412
460
|
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).createIndex(fieldOrSpec, options).then(function (res) {
|
|
461
|
+
monitor_4.finish();
|
|
413
462
|
resolve(res);
|
|
414
463
|
}, function (err) {
|
|
464
|
+
monitor_4.finish();
|
|
415
465
|
console.log(new Date(), 'Error Setting Up Index for Collection', _this.collectionName, fieldOrSpec, options, err);
|
|
416
466
|
reject(err);
|
|
417
467
|
});
|
|
@@ -419,16 +469,27 @@ var Collection = /** @class */ (function () {
|
|
|
419
469
|
});
|
|
420
470
|
};
|
|
421
471
|
Collection.prototype.createIndexes = function (indexSpecs, options) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
472
|
+
var _this = this;
|
|
473
|
+
return new Promise(function (resolve, reject) {
|
|
474
|
+
if (index_1.ResolveIOServer.getMainDB().collection(_this.collectionName)) {
|
|
475
|
+
var monitor_5 = new monitor_manager_1.MonitorMongo('createIndexes', _this.collectionName, JSON.stringify([indexSpecs, options]));
|
|
476
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).createIndexes(indexSpecs, options).then(function (res) {
|
|
477
|
+
monitor_5.finish();
|
|
478
|
+
resolve(res);
|
|
479
|
+
}, function (err) {
|
|
480
|
+
monitor_5.finish();
|
|
481
|
+
console.log(new Date(), 'Error Setting Up Indexes for Collection', _this.collectionName, indexSpecs, options, err);
|
|
482
|
+
reject(err);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
});
|
|
425
486
|
};
|
|
426
487
|
Collection.prototype.deleteMany = function (filter, options, bypassLogs) {
|
|
427
488
|
var _this = this;
|
|
428
489
|
if (filter === void 0) { filter = {}; }
|
|
429
490
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
430
491
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
431
|
-
var docs, i, doc, versionDoc;
|
|
492
|
+
var docs, i, doc, versionDoc, monitor;
|
|
432
493
|
var _this = this;
|
|
433
494
|
return __generator(this, function (_a) {
|
|
434
495
|
switch (_a.label) {
|
|
@@ -460,7 +521,9 @@ var Collection = /** @class */ (function () {
|
|
|
460
521
|
}
|
|
461
522
|
_a.label = 2;
|
|
462
523
|
case 2:
|
|
524
|
+
monitor = new monitor_manager_1.MonitorMongo('deleteMany', this.collectionName, JSON.stringify([filter, options]));
|
|
463
525
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteMany(filter, options).then(function (res) {
|
|
526
|
+
monitor.finish();
|
|
464
527
|
if (res.acknowledged) {
|
|
465
528
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
466
529
|
resolve(res.deletedCount);
|
|
@@ -468,7 +531,11 @@ var Collection = /** @class */ (function () {
|
|
|
468
531
|
else {
|
|
469
532
|
reject(res.acknowledged);
|
|
470
533
|
}
|
|
471
|
-
}, function (err) {
|
|
534
|
+
}, function (err) {
|
|
535
|
+
monitor.finish();
|
|
536
|
+
console.log(new Date(), 'Error Delete Many', _this.collectionName, filter, options, err);
|
|
537
|
+
reject(err);
|
|
538
|
+
});
|
|
472
539
|
return [2 /*return*/];
|
|
473
540
|
}
|
|
474
541
|
});
|
|
@@ -479,12 +546,15 @@ var Collection = /** @class */ (function () {
|
|
|
479
546
|
if (filter === void 0) { filter = {}; }
|
|
480
547
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
481
548
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
549
|
+
var monitor_6, monitor_7;
|
|
482
550
|
var _this = this;
|
|
483
551
|
return __generator(this, function (_a) {
|
|
484
552
|
if (this.createLogs && !bypassLogs) {
|
|
553
|
+
monitor_6 = new monitor_manager_1.MonitorMongo('findOneAndDelete', this.collectionName, JSON.stringify([filter, options]));
|
|
485
554
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndDelete(filter, options).then(function (returnVal) { return __awaiter(_this, void 0, void 0, function () {
|
|
486
555
|
var doc, versionDoc;
|
|
487
556
|
return __generator(this, function (_a) {
|
|
557
|
+
monitor_6.finish();
|
|
488
558
|
doc = returnVal.value;
|
|
489
559
|
if (doc) {
|
|
490
560
|
if (this.createLogs && !bypassLogs) {
|
|
@@ -515,10 +585,16 @@ var Collection = /** @class */ (function () {
|
|
|
515
585
|
}
|
|
516
586
|
return [2 /*return*/];
|
|
517
587
|
});
|
|
518
|
-
}); }, function (err) {
|
|
588
|
+
}); }, function (err) {
|
|
589
|
+
monitor_6.finish();
|
|
590
|
+
console.log(new Date(), 'Error Find One And Delete', _this.collectionName, filter, options, err);
|
|
591
|
+
reject(err);
|
|
592
|
+
});
|
|
519
593
|
}
|
|
520
594
|
else {
|
|
595
|
+
monitor_7 = new monitor_manager_1.MonitorMongo('deleteOne', this.collectionName, JSON.stringify([filter, options]));
|
|
521
596
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).deleteOne(filter, options).then(function (res) {
|
|
597
|
+
monitor_7.finish();
|
|
522
598
|
if (res.acknowledged) {
|
|
523
599
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
524
600
|
resolve(res.deletedCount);
|
|
@@ -526,29 +602,79 @@ var Collection = /** @class */ (function () {
|
|
|
526
602
|
else {
|
|
527
603
|
reject(res.acknowledged);
|
|
528
604
|
}
|
|
529
|
-
}, function (err) {
|
|
605
|
+
}, function (err) {
|
|
606
|
+
monitor_7.finish();
|
|
607
|
+
console.log(new Date(), 'Error Delete One', _this.collectionName, filter, options, err);
|
|
608
|
+
reject(err);
|
|
609
|
+
});
|
|
530
610
|
}
|
|
531
611
|
return [2 /*return*/];
|
|
532
612
|
});
|
|
533
613
|
}); });
|
|
534
614
|
};
|
|
535
615
|
Collection.prototype.distinct = function (key, filter, options) {
|
|
536
|
-
|
|
616
|
+
var _this = this;
|
|
617
|
+
return new Promise(function (resolve, reject) {
|
|
618
|
+
var monitor = new monitor_manager_1.MonitorMongo('distinct', _this.collectionName, JSON.stringify([key, filter, options]));
|
|
619
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).distinct(key, filter, options).then(function (res) {
|
|
620
|
+
monitor.finish();
|
|
621
|
+
resolve(res);
|
|
622
|
+
}, function (err) {
|
|
623
|
+
monitor.finish();
|
|
624
|
+
console.log(new Date(), 'Error Distinct', _this.collectionName, filter, options, err);
|
|
625
|
+
reject(err);
|
|
626
|
+
});
|
|
627
|
+
});
|
|
537
628
|
};
|
|
538
629
|
Collection.prototype.drop = function (options) {
|
|
539
|
-
|
|
630
|
+
var _this = this;
|
|
631
|
+
return new Promise(function (resolve, reject) {
|
|
632
|
+
var monitor = new monitor_manager_1.MonitorMongo('drop', _this.collectionName, JSON.stringify([options]));
|
|
633
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).drop(options).then(function (res) {
|
|
634
|
+
monitor.finish();
|
|
635
|
+
resolve(res);
|
|
636
|
+
}, function (err) {
|
|
637
|
+
monitor.finish();
|
|
638
|
+
console.log(new Date(), 'Error Count Documents', _this.collectionName, options, err);
|
|
639
|
+
reject(err);
|
|
640
|
+
});
|
|
641
|
+
});
|
|
540
642
|
};
|
|
541
643
|
Collection.prototype.dropIndex = function (indexName, options) {
|
|
542
|
-
|
|
644
|
+
var _this = this;
|
|
645
|
+
return new Promise(function (resolve, reject) {
|
|
646
|
+
var monitor = new monitor_manager_1.MonitorMongo('dropIndex', _this.collectionName, JSON.stringify([indexName, options]));
|
|
647
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).dropIndex(indexName, options).then(function (res) {
|
|
648
|
+
monitor.finish();
|
|
649
|
+
resolve(res);
|
|
650
|
+
}, function (err) {
|
|
651
|
+
monitor.finish();
|
|
652
|
+
console.log(new Date(), 'Error Drop Index', _this.collectionName, indexName, options, err);
|
|
653
|
+
reject(err);
|
|
654
|
+
});
|
|
655
|
+
});
|
|
543
656
|
};
|
|
544
657
|
Collection.prototype.dropIndexes = function (options) {
|
|
545
|
-
|
|
658
|
+
var _this = this;
|
|
659
|
+
return new Promise(function (resolve, reject) {
|
|
660
|
+
var monitor = new monitor_manager_1.MonitorMongo('dropIndexes', _this.collectionName, JSON.stringify([options]));
|
|
661
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).dropIndexes(options).then(function (res) {
|
|
662
|
+
monitor.finish();
|
|
663
|
+
resolve(res);
|
|
664
|
+
}, function (err) {
|
|
665
|
+
monitor.finish();
|
|
666
|
+
console.log(new Date(), 'Error Drop Indexes', _this.collectionName, options, err);
|
|
667
|
+
reject(err);
|
|
668
|
+
});
|
|
669
|
+
});
|
|
546
670
|
};
|
|
547
671
|
Collection.prototype.find = function (filter, options, skipCache) {
|
|
548
672
|
var _this = this;
|
|
549
673
|
if (filter === void 0) { filter = {}; }
|
|
550
674
|
if (skipCache === void 0) { skipCache = false; }
|
|
551
675
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
676
|
+
var monitor_8;
|
|
677
|
+
var _this = this;
|
|
552
678
|
return __generator(this, function (_a) {
|
|
553
679
|
if (!skipCache) {
|
|
554
680
|
index_1.ResolveIOServer.getMongoManager().addToQueue({
|
|
@@ -574,7 +700,15 @@ var Collection = /** @class */ (function () {
|
|
|
574
700
|
});
|
|
575
701
|
}
|
|
576
702
|
else {
|
|
577
|
-
|
|
703
|
+
monitor_8 = new monitor_manager_1.MonitorMongo('find', this.collectionName, JSON.stringify([filter, options]));
|
|
704
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).toArray().then(function (res) {
|
|
705
|
+
monitor_8.finish();
|
|
706
|
+
resolve(res);
|
|
707
|
+
}, function (err) {
|
|
708
|
+
monitor_8.finish();
|
|
709
|
+
console.log(new Date(), 'Error Find', _this.collectionName, filter, options, err);
|
|
710
|
+
reject(err);
|
|
711
|
+
});
|
|
578
712
|
}
|
|
579
713
|
return [2 /*return*/];
|
|
580
714
|
});
|
|
@@ -583,20 +717,51 @@ var Collection = /** @class */ (function () {
|
|
|
583
717
|
Collection.prototype.findById = function (id, options) {
|
|
584
718
|
var _this = this;
|
|
585
719
|
return new Promise(function (resolve, reject) {
|
|
586
|
-
|
|
720
|
+
var monitor = new monitor_manager_1.MonitorMongo('findById', _this.collectionName, JSON.stringify([{ _id: id }, options]));
|
|
721
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).findOne({ _id: id }, options).then(function (res) {
|
|
722
|
+
monitor.finish();
|
|
723
|
+
resolve(res);
|
|
724
|
+
}, function (err) {
|
|
725
|
+
monitor.finish();
|
|
726
|
+
console.log(new Date(), 'Error Find By Id', _this.collectionName, { _id: id }, options, err);
|
|
727
|
+
reject(err);
|
|
728
|
+
});
|
|
587
729
|
});
|
|
588
730
|
};
|
|
589
731
|
Collection.prototype.findCount = function (filter, options) {
|
|
732
|
+
var _this = this;
|
|
590
733
|
if (filter === void 0) { filter = {}; }
|
|
591
|
-
return
|
|
734
|
+
return new Promise(function (resolve, reject) {
|
|
735
|
+
var monitor = new monitor_manager_1.MonitorMongo('findCount', _this.collectionName, JSON.stringify([filter, options]));
|
|
736
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).find(filter, options).count().then(function (res) {
|
|
737
|
+
monitor.finish();
|
|
738
|
+
resolve(res);
|
|
739
|
+
}, function (err) {
|
|
740
|
+
monitor.finish();
|
|
741
|
+
console.log(new Date(), 'Error Find Count', _this.collectionName, filter, options, err);
|
|
742
|
+
reject(err);
|
|
743
|
+
});
|
|
744
|
+
});
|
|
592
745
|
};
|
|
593
746
|
Collection.prototype.findCursor = function (filter, options) {
|
|
594
747
|
if (filter === void 0) { filter = {}; }
|
|
595
|
-
|
|
748
|
+
var monitor = new monitor_manager_1.MonitorMongo('findCursor', this.collectionName, JSON.stringify([filter, options]));
|
|
749
|
+
var cursor = index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options);
|
|
750
|
+
cursor.on('close', function (ev) {
|
|
751
|
+
monitor.finish();
|
|
752
|
+
return ev;
|
|
753
|
+
});
|
|
754
|
+
return cursor;
|
|
596
755
|
};
|
|
597
756
|
Collection.prototype.findStream = function (filter, options, streamOptions) {
|
|
598
757
|
if (filter === void 0) { filter = {}; }
|
|
599
|
-
|
|
758
|
+
var monitor = new monitor_manager_1.MonitorMongo('findStream', this.collectionName, JSON.stringify([filter, options, streamOptions]));
|
|
759
|
+
var stream = index_1.ResolveIOServer.getMainDB().collection(this.collectionName).find(filter, options).stream(streamOptions);
|
|
760
|
+
stream.on('end', function (ev) {
|
|
761
|
+
monitor.finish();
|
|
762
|
+
return ev;
|
|
763
|
+
});
|
|
764
|
+
return stream;
|
|
600
765
|
};
|
|
601
766
|
Collection.prototype.findOne = function (filter, options, skipCache) {
|
|
602
767
|
var _this = this;
|
|
@@ -627,7 +792,15 @@ var Collection = /** @class */ (function () {
|
|
|
627
792
|
});
|
|
628
793
|
}
|
|
629
794
|
else {
|
|
630
|
-
|
|
795
|
+
var monitor_9 = new monitor_manager_1.MonitorMongo('findOne', _this.collectionName, JSON.stringify([filter, options]));
|
|
796
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).findOne(filter, options).then(function (res) {
|
|
797
|
+
monitor_9.finish();
|
|
798
|
+
resolve(res);
|
|
799
|
+
}, function (err) {
|
|
800
|
+
monitor_9.finish();
|
|
801
|
+
console.log(new Date(), 'Error Find One', _this.collectionName, filter, options, err);
|
|
802
|
+
reject(err);
|
|
803
|
+
});
|
|
631
804
|
}
|
|
632
805
|
});
|
|
633
806
|
};
|
|
@@ -636,9 +809,12 @@ var Collection = /** @class */ (function () {
|
|
|
636
809
|
if (filter === void 0) { filter = {}; }
|
|
637
810
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
638
811
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
812
|
+
var monitor;
|
|
639
813
|
var _this = this;
|
|
640
814
|
return __generator(this, function (_a) {
|
|
815
|
+
monitor = new monitor_manager_1.MonitorMongo('findOneAndDelete', this.collectionName, JSON.stringify([filter, options]));
|
|
641
816
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndDelete(filter, options).then(function (res) {
|
|
817
|
+
monitor.finish();
|
|
642
818
|
var doc = res.value;
|
|
643
819
|
if (doc) {
|
|
644
820
|
if (_this.createLogs && !bypassLogs) {
|
|
@@ -666,7 +842,11 @@ var Collection = /** @class */ (function () {
|
|
|
666
842
|
else {
|
|
667
843
|
resolve(null);
|
|
668
844
|
}
|
|
669
|
-
}, function (err) {
|
|
845
|
+
}, function (err) {
|
|
846
|
+
monitor.finish();
|
|
847
|
+
console.log(new Date(), 'Error Find One And Delete', _this.collectionName, filter, options, err);
|
|
848
|
+
reject(err);
|
|
849
|
+
});
|
|
670
850
|
return [2 /*return*/];
|
|
671
851
|
});
|
|
672
852
|
}); });
|
|
@@ -677,7 +857,7 @@ var Collection = /** @class */ (function () {
|
|
|
677
857
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
678
858
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
679
859
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
680
|
-
var validation, isValid, date;
|
|
860
|
+
var validation, isValid, date, monitor;
|
|
681
861
|
var _this = this;
|
|
682
862
|
return __generator(this, function (_a) {
|
|
683
863
|
if (this.checkSchema && !bypassCheckSchema) {
|
|
@@ -705,7 +885,9 @@ var Collection = /** @class */ (function () {
|
|
|
705
885
|
replacement['createdAt'] = date;
|
|
706
886
|
}
|
|
707
887
|
}
|
|
888
|
+
monitor = new monitor_manager_1.MonitorMongo('findOneAndReplace', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
708
889
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndReplace(filter, replacement, options).then(function (res) {
|
|
890
|
+
monitor.finish();
|
|
709
891
|
var doc = res.value;
|
|
710
892
|
if (doc) {
|
|
711
893
|
if (_this.createLogs && !bypassLogs) {
|
|
@@ -733,7 +915,11 @@ var Collection = /** @class */ (function () {
|
|
|
733
915
|
else {
|
|
734
916
|
resolve(null);
|
|
735
917
|
}
|
|
736
|
-
}, function (err) {
|
|
918
|
+
}, function (err) {
|
|
919
|
+
monitor.finish();
|
|
920
|
+
console.log(new Date(), 'Error Find One And Replace', _this.collectionName, filter, options, err);
|
|
921
|
+
reject(err);
|
|
922
|
+
});
|
|
737
923
|
return [2 /*return*/];
|
|
738
924
|
});
|
|
739
925
|
}); });
|
|
@@ -744,7 +930,7 @@ var Collection = /** @class */ (function () {
|
|
|
744
930
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
745
931
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
746
932
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
747
|
-
var validation, isValid, date;
|
|
933
|
+
var validation, isValid, date, monitor;
|
|
748
934
|
var _this = this;
|
|
749
935
|
return __generator(this, function (_a) {
|
|
750
936
|
if (this.checkSchema && !bypassCheckSchema) {
|
|
@@ -789,7 +975,9 @@ var Collection = /** @class */ (function () {
|
|
|
789
975
|
}
|
|
790
976
|
}
|
|
791
977
|
}
|
|
978
|
+
monitor = new monitor_manager_1.MonitorMongo('findOneAndUpdate', this.collectionName, JSON.stringify([filter, update, options]));
|
|
792
979
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndUpdate(filter, update, options).then(function (res) {
|
|
980
|
+
monitor.finish();
|
|
793
981
|
var doc = res.value;
|
|
794
982
|
if (doc) {
|
|
795
983
|
if (_this.createLogs && !bypassLogs) {
|
|
@@ -818,6 +1006,8 @@ var Collection = /** @class */ (function () {
|
|
|
818
1006
|
resolve(null);
|
|
819
1007
|
}
|
|
820
1008
|
}, function (err) {
|
|
1009
|
+
monitor.finish();
|
|
1010
|
+
console.log(new Date(), 'Error Find One And Update', _this.collectionName, filter, options, err);
|
|
821
1011
|
reject(err);
|
|
822
1012
|
});
|
|
823
1013
|
return [2 /*return*/];
|
|
@@ -825,17 +1015,39 @@ var Collection = /** @class */ (function () {
|
|
|
825
1015
|
}); });
|
|
826
1016
|
};
|
|
827
1017
|
Collection.prototype.indexes = function (options) {
|
|
828
|
-
|
|
1018
|
+
var _this = this;
|
|
1019
|
+
return new Promise(function (resolve, reject) {
|
|
1020
|
+
var monitor = new monitor_manager_1.MonitorMongo('indexes', _this.collectionName, JSON.stringify([options]));
|
|
1021
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).indexes(options).then(function (res) {
|
|
1022
|
+
monitor.finish();
|
|
1023
|
+
resolve(res);
|
|
1024
|
+
}, function (err) {
|
|
1025
|
+
monitor.finish();
|
|
1026
|
+
console.log(new Date(), 'Error Indexes', _this.collectionName, options, err);
|
|
1027
|
+
reject(err);
|
|
1028
|
+
});
|
|
1029
|
+
});
|
|
829
1030
|
};
|
|
830
1031
|
Collection.prototype.indexExists = function (indexes, options) {
|
|
831
|
-
|
|
1032
|
+
var _this = this;
|
|
1033
|
+
return new Promise(function (resolve, reject) {
|
|
1034
|
+
var monitor = new monitor_manager_1.MonitorMongo('indexExists', _this.collectionName, JSON.stringify([indexes, options]));
|
|
1035
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).indexExists(indexes, options).then(function (res) {
|
|
1036
|
+
monitor.finish();
|
|
1037
|
+
resolve(res);
|
|
1038
|
+
}, function (err) {
|
|
1039
|
+
monitor.finish();
|
|
1040
|
+
console.log(new Date(), 'Error Index Exists', _this.collectionName, indexes, options, err);
|
|
1041
|
+
reject(err);
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
832
1044
|
};
|
|
833
1045
|
Collection.prototype.insertMany = function (docs, options, bypassLogs, bypassCheckSchema) {
|
|
834
1046
|
var _this = this;
|
|
835
1047
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
836
1048
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
837
1049
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
838
|
-
var validationResults, validDocs, i, doc, date;
|
|
1050
|
+
var validationResults, validDocs, i, doc, date, monitor_10;
|
|
839
1051
|
var _this = this;
|
|
840
1052
|
return __generator(this, function (_a) {
|
|
841
1053
|
if (!docs.length) {
|
|
@@ -884,7 +1096,9 @@ var Collection = /** @class */ (function () {
|
|
|
884
1096
|
}
|
|
885
1097
|
}
|
|
886
1098
|
if (validDocs.length) {
|
|
1099
|
+
monitor_10 = new monitor_manager_1.MonitorMongo('insertMany', this.collectionName, JSON.stringify([validDocs, options]));
|
|
887
1100
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).insertMany(validDocs, options).then(function (res) {
|
|
1101
|
+
monitor_10.finish();
|
|
888
1102
|
if (res.acknowledged) {
|
|
889
1103
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
890
1104
|
resolve(validDocs);
|
|
@@ -893,6 +1107,8 @@ var Collection = /** @class */ (function () {
|
|
|
893
1107
|
reject(res.acknowledged);
|
|
894
1108
|
}
|
|
895
1109
|
}, function (err) {
|
|
1110
|
+
monitor_10.finish();
|
|
1111
|
+
console.log(new Date(), 'Error Insert Many', _this.collectionName, validDocs, options, err);
|
|
896
1112
|
reject(err);
|
|
897
1113
|
});
|
|
898
1114
|
}
|
|
@@ -905,7 +1121,7 @@ var Collection = /** @class */ (function () {
|
|
|
905
1121
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
906
1122
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
907
1123
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
908
|
-
var validation, isValid, date;
|
|
1124
|
+
var validation, isValid, date, monitor;
|
|
909
1125
|
var _this = this;
|
|
910
1126
|
return __generator(this, function (_a) {
|
|
911
1127
|
if (!doc['_id']) {
|
|
@@ -943,7 +1159,9 @@ var Collection = /** @class */ (function () {
|
|
|
943
1159
|
if (this.useVersions && !doc.hasOwnProperty('__v')) {
|
|
944
1160
|
doc['__v'] = 0;
|
|
945
1161
|
}
|
|
1162
|
+
monitor = new monitor_manager_1.MonitorMongo('insertOne', this.collectionName, JSON.stringify([doc, options]));
|
|
946
1163
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).insertOne(doc, options).then(function (res) {
|
|
1164
|
+
monitor.finish();
|
|
947
1165
|
if (res.acknowledged) {
|
|
948
1166
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
949
1167
|
resolve(doc);
|
|
@@ -952,6 +1170,8 @@ var Collection = /** @class */ (function () {
|
|
|
952
1170
|
reject(res.acknowledged);
|
|
953
1171
|
}
|
|
954
1172
|
}, function (err) {
|
|
1173
|
+
monitor.finish();
|
|
1174
|
+
console.log(new Date(), 'Error Insert One', _this.collectionName, doc, options, err);
|
|
955
1175
|
reject(err);
|
|
956
1176
|
});
|
|
957
1177
|
return [2 /*return*/];
|
|
@@ -959,10 +1179,27 @@ var Collection = /** @class */ (function () {
|
|
|
959
1179
|
}); });
|
|
960
1180
|
};
|
|
961
1181
|
Collection.prototype.listIndexes = function (options) {
|
|
962
|
-
|
|
1182
|
+
var monitor = new monitor_manager_1.MonitorMongo('listIndexes', this.collectionName, JSON.stringify([options]));
|
|
1183
|
+
var cursor = index_1.ResolveIOServer.getMainDB().collection(this.collectionName).listIndexes(options);
|
|
1184
|
+
cursor.on('close', function (ev) {
|
|
1185
|
+
monitor.finish();
|
|
1186
|
+
return ev;
|
|
1187
|
+
});
|
|
1188
|
+
return cursor;
|
|
963
1189
|
};
|
|
964
1190
|
Collection.prototype.rename = function (newName, options) {
|
|
965
|
-
|
|
1191
|
+
var _this = this;
|
|
1192
|
+
return new Promise(function (resolve, reject) {
|
|
1193
|
+
var monitor = new monitor_manager_1.MonitorMongo('rename', _this.collectionName, JSON.stringify([newName, options]));
|
|
1194
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).rename(newName, options).then(function (res) {
|
|
1195
|
+
monitor.finish();
|
|
1196
|
+
resolve(res);
|
|
1197
|
+
}, function (err) {
|
|
1198
|
+
monitor.finish();
|
|
1199
|
+
console.log(new Date(), 'Error Rename', _this.collectionName, newName, options, err);
|
|
1200
|
+
reject(err);
|
|
1201
|
+
});
|
|
1202
|
+
});
|
|
966
1203
|
};
|
|
967
1204
|
Collection.prototype.replaceOne = function (filter, replacement, options, bypassLogs, bypassCheckSchema, doc) {
|
|
968
1205
|
var _this = this;
|
|
@@ -970,7 +1207,7 @@ var Collection = /** @class */ (function () {
|
|
|
970
1207
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
971
1208
|
if (doc === void 0) { doc = null; }
|
|
972
1209
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
973
|
-
var validation, isValid, date, versionDoc, prevDoc, docId, docVersion,
|
|
1210
|
+
var validation, isValid, date, versionDoc, monitor_11, prevDoc, docId, docVersion, updatedDoc_1, monitor_12, monitor_13, monitor_14, monitor_15;
|
|
974
1211
|
var _this = this;
|
|
975
1212
|
return __generator(this, function (_a) {
|
|
976
1213
|
switch (_a.label) {
|
|
@@ -1022,7 +1259,9 @@ var Collection = /** @class */ (function () {
|
|
|
1022
1259
|
route: ''
|
|
1023
1260
|
});
|
|
1024
1261
|
}
|
|
1262
|
+
monitor_11 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1025
1263
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1264
|
+
monitor_11.finish();
|
|
1026
1265
|
if (res.acknowledged) {
|
|
1027
1266
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1028
1267
|
resolve(res.modifiedCount);
|
|
@@ -1031,6 +1270,8 @@ var Collection = /** @class */ (function () {
|
|
|
1031
1270
|
reject(res.acknowledged);
|
|
1032
1271
|
}
|
|
1033
1272
|
}, function (err) {
|
|
1273
|
+
monitor_11.finish();
|
|
1274
|
+
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, replacement, options, err);
|
|
1034
1275
|
reject(err);
|
|
1035
1276
|
});
|
|
1036
1277
|
return [3 /*break*/, 5];
|
|
@@ -1047,16 +1288,16 @@ var Collection = /** @class */ (function () {
|
|
|
1047
1288
|
if (prevDoc) {
|
|
1048
1289
|
docId = doc['_id'];
|
|
1049
1290
|
docVersion = doc['__v'];
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1291
|
+
updatedDoc_1 = common_1.getMongoMergeUpdatedDoc(replacement, doc, prevDoc);
|
|
1292
|
+
updatedDoc_1['_id'] = docId;
|
|
1293
|
+
updatedDoc_1['__v'] = docVersion + 1;
|
|
1053
1294
|
if (this.createLogs && !bypassLogs) {
|
|
1054
1295
|
log_collection_1.Logs.insertOne({
|
|
1055
1296
|
_id: objectIdHexString(),
|
|
1056
1297
|
type: 'document',
|
|
1057
1298
|
collection: this.collectionName,
|
|
1058
1299
|
id_document: doc['_id'],
|
|
1059
|
-
payload: common_1.getBinarySize(JSON.stringify(['invalidVersion - merge', doc, filter,
|
|
1300
|
+
payload: common_1.getBinarySize(JSON.stringify(['invalidVersion - merge', doc, filter, updatedDoc_1, options])) < 200000 ? JSON.stringify(['invalidVersion - merge', doc, filter, updatedDoc_1, options], null, 2) : 'Too Big',
|
|
1060
1301
|
method: 'replaceOne',
|
|
1061
1302
|
id_user: '',
|
|
1062
1303
|
user: '',
|
|
@@ -1064,7 +1305,9 @@ var Collection = /** @class */ (function () {
|
|
|
1064
1305
|
route: ''
|
|
1065
1306
|
});
|
|
1066
1307
|
}
|
|
1067
|
-
|
|
1308
|
+
monitor_12 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, updatedDoc_1, options]));
|
|
1309
|
+
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, updatedDoc_1, options).then(function (res) {
|
|
1310
|
+
monitor_12.finish();
|
|
1068
1311
|
if (res.acknowledged) {
|
|
1069
1312
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1070
1313
|
resolve(res.modifiedCount);
|
|
@@ -1073,6 +1316,8 @@ var Collection = /** @class */ (function () {
|
|
|
1073
1316
|
reject(res.acknowledged);
|
|
1074
1317
|
}
|
|
1075
1318
|
}, function (err) {
|
|
1319
|
+
monitor_12.finish();
|
|
1320
|
+
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, updatedDoc_1, options, err);
|
|
1076
1321
|
reject(err);
|
|
1077
1322
|
});
|
|
1078
1323
|
}
|
|
@@ -1104,7 +1349,9 @@ var Collection = /** @class */ (function () {
|
|
|
1104
1349
|
route: ''
|
|
1105
1350
|
});
|
|
1106
1351
|
}
|
|
1352
|
+
monitor_13 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1107
1353
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1354
|
+
monitor_13.finish();
|
|
1108
1355
|
if (res.acknowledged) {
|
|
1109
1356
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1110
1357
|
resolve(res.modifiedCount);
|
|
@@ -1113,6 +1360,8 @@ var Collection = /** @class */ (function () {
|
|
|
1113
1360
|
reject(res.acknowledged);
|
|
1114
1361
|
}
|
|
1115
1362
|
}, function (err) {
|
|
1363
|
+
monitor_13.finish();
|
|
1364
|
+
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, replacement, options, err);
|
|
1116
1365
|
reject(err);
|
|
1117
1366
|
});
|
|
1118
1367
|
}
|
|
@@ -1138,7 +1387,9 @@ var Collection = /** @class */ (function () {
|
|
|
1138
1387
|
else {
|
|
1139
1388
|
options.returnDocument = 'before';
|
|
1140
1389
|
}
|
|
1390
|
+
monitor_14 = new monitor_manager_1.MonitorMongo('findOneAndReplace', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1141
1391
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndReplace(filter, replacement, options).then(function (res) {
|
|
1392
|
+
monitor_14.finish();
|
|
1142
1393
|
var doc = res.value;
|
|
1143
1394
|
if (doc) {
|
|
1144
1395
|
log_collection_1.Logs.insertOne({
|
|
@@ -1170,10 +1421,16 @@ var Collection = /** @class */ (function () {
|
|
|
1170
1421
|
}
|
|
1171
1422
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1172
1423
|
resolve(res.ok);
|
|
1173
|
-
}, function (err) {
|
|
1424
|
+
}, function (err) {
|
|
1425
|
+
monitor_14.finish();
|
|
1426
|
+
console.log(new Date(), 'Error Find One And Replace', _this.collectionName, filter, replacement, options, err);
|
|
1427
|
+
reject(err);
|
|
1428
|
+
});
|
|
1174
1429
|
}
|
|
1175
1430
|
else {
|
|
1431
|
+
monitor_15 = new monitor_manager_1.MonitorMongo('replaceOne', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
1176
1432
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).replaceOne(filter, replacement, options).then(function (res) {
|
|
1433
|
+
monitor_15.finish();
|
|
1177
1434
|
if (res.acknowledged) {
|
|
1178
1435
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1179
1436
|
resolve(res.modifiedCount);
|
|
@@ -1182,6 +1439,8 @@ var Collection = /** @class */ (function () {
|
|
|
1182
1439
|
reject(res.acknowledged);
|
|
1183
1440
|
}
|
|
1184
1441
|
}, function (err) {
|
|
1442
|
+
monitor_15.finish();
|
|
1443
|
+
console.log(new Date(), 'Error Replace One', _this.collectionName, filter, replacement, options, err);
|
|
1185
1444
|
reject(err);
|
|
1186
1445
|
});
|
|
1187
1446
|
}
|
|
@@ -1192,7 +1451,18 @@ var Collection = /** @class */ (function () {
|
|
|
1192
1451
|
}); });
|
|
1193
1452
|
};
|
|
1194
1453
|
Collection.prototype.stats = function (options) {
|
|
1195
|
-
|
|
1454
|
+
var _this = this;
|
|
1455
|
+
return new Promise(function (resolve, reject) {
|
|
1456
|
+
var monitor = new monitor_manager_1.MonitorMongo('stats', _this.collectionName, JSON.stringify([options]));
|
|
1457
|
+
index_1.ResolveIOServer.getMainDB().collection(_this.collectionName).stats(options).then(function (res) {
|
|
1458
|
+
monitor.finish();
|
|
1459
|
+
resolve(res);
|
|
1460
|
+
}, function (err) {
|
|
1461
|
+
monitor.finish();
|
|
1462
|
+
console.log(new Date(), 'Error Stats', _this.collectionName, options, err);
|
|
1463
|
+
reject(err);
|
|
1464
|
+
});
|
|
1465
|
+
});
|
|
1196
1466
|
};
|
|
1197
1467
|
Collection.prototype.updateMany = function (filter, update, options, bypassLogs, bypassCheckSchema, bypassVersions) {
|
|
1198
1468
|
var _this = this;
|
|
@@ -1200,7 +1470,7 @@ var Collection = /** @class */ (function () {
|
|
|
1200
1470
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
1201
1471
|
if (bypassVersions === void 0) { bypassVersions = false; }
|
|
1202
1472
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1203
|
-
var date, validation, isValid, docs, i, doc, versionDoc;
|
|
1473
|
+
var date, validation, isValid, docs, i, doc, versionDoc, monitor;
|
|
1204
1474
|
var _this = this;
|
|
1205
1475
|
return __generator(this, function (_a) {
|
|
1206
1476
|
switch (_a.label) {
|
|
@@ -1263,7 +1533,9 @@ var Collection = /** @class */ (function () {
|
|
|
1263
1533
|
}
|
|
1264
1534
|
_a.label = 2;
|
|
1265
1535
|
case 2:
|
|
1536
|
+
monitor = new monitor_manager_1.MonitorMongo('updateMany', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1266
1537
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateMany(filter, update, options).then(function (res) {
|
|
1538
|
+
monitor.finish();
|
|
1267
1539
|
if (res.acknowledged) {
|
|
1268
1540
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1269
1541
|
resolve(res.modifiedCount);
|
|
@@ -1271,7 +1543,11 @@ var Collection = /** @class */ (function () {
|
|
|
1271
1543
|
else {
|
|
1272
1544
|
reject(res.acknowledged);
|
|
1273
1545
|
}
|
|
1274
|
-
}, function (err) {
|
|
1546
|
+
}, function (err) {
|
|
1547
|
+
monitor.finish();
|
|
1548
|
+
console.log(new Date(), 'Error Update Many', _this.collectionName, filter, update, options, err);
|
|
1549
|
+
reject(err);
|
|
1550
|
+
});
|
|
1275
1551
|
return [2 /*return*/];
|
|
1276
1552
|
}
|
|
1277
1553
|
});
|
|
@@ -1282,7 +1558,7 @@ var Collection = /** @class */ (function () {
|
|
|
1282
1558
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1283
1559
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
1284
1560
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1285
|
-
var validation, isValid, date, doc, versionDoc;
|
|
1561
|
+
var validation, isValid, date, doc, versionDoc, monitor_16, monitor_17, monitor_18, monitor_19;
|
|
1286
1562
|
var _this = this;
|
|
1287
1563
|
return __generator(this, function (_a) {
|
|
1288
1564
|
switch (_a.label) {
|
|
@@ -1339,7 +1615,9 @@ var Collection = /** @class */ (function () {
|
|
|
1339
1615
|
update.$inc.__v = 1;
|
|
1340
1616
|
}
|
|
1341
1617
|
}
|
|
1618
|
+
monitor_16 = new monitor_manager_1.MonitorMongo('updateOne', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1342
1619
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1620
|
+
monitor_16.finish();
|
|
1343
1621
|
if (res.acknowledged) {
|
|
1344
1622
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1345
1623
|
resolve(res.modifiedCount);
|
|
@@ -1347,7 +1625,11 @@ var Collection = /** @class */ (function () {
|
|
|
1347
1625
|
else {
|
|
1348
1626
|
reject(res.acknowledged);
|
|
1349
1627
|
}
|
|
1350
|
-
}, function (err) {
|
|
1628
|
+
}, function (err) {
|
|
1629
|
+
monitor_16.finish();
|
|
1630
|
+
console.log(new Date(), 'Error Update One', _this.collectionName, filter, update, options, err);
|
|
1631
|
+
reject(err);
|
|
1632
|
+
});
|
|
1351
1633
|
}
|
|
1352
1634
|
else if (options && options.upsert) {
|
|
1353
1635
|
if (!update.$setOnInsert) {
|
|
@@ -1387,7 +1669,9 @@ var Collection = /** @class */ (function () {
|
|
|
1387
1669
|
route: ''
|
|
1388
1670
|
});
|
|
1389
1671
|
}
|
|
1672
|
+
monitor_17 = new monitor_manager_1.MonitorMongo('updateOne', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1390
1673
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1674
|
+
monitor_17.finish();
|
|
1391
1675
|
if (res.acknowledged) {
|
|
1392
1676
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1393
1677
|
resolve(res.modifiedCount);
|
|
@@ -1395,7 +1679,11 @@ var Collection = /** @class */ (function () {
|
|
|
1395
1679
|
else {
|
|
1396
1680
|
reject(res.acknowledged);
|
|
1397
1681
|
}
|
|
1398
|
-
}, function (err) {
|
|
1682
|
+
}, function (err) {
|
|
1683
|
+
monitor_17.finish();
|
|
1684
|
+
console.log(new Date(), 'Error Update One', _this.collectionName, filter, update, options, err);
|
|
1685
|
+
reject(err);
|
|
1686
|
+
});
|
|
1399
1687
|
}
|
|
1400
1688
|
else {
|
|
1401
1689
|
reject('No Document');
|
|
@@ -1432,7 +1720,9 @@ var Collection = /** @class */ (function () {
|
|
|
1432
1720
|
else {
|
|
1433
1721
|
options.returnDocument = 'before';
|
|
1434
1722
|
}
|
|
1723
|
+
monitor_18 = new monitor_manager_1.MonitorMongo('findOneAndUpdate', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1435
1724
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).findOneAndUpdate(filter, update, options).then(function (res) {
|
|
1725
|
+
monitor_18.finish();
|
|
1436
1726
|
var doc = res.value;
|
|
1437
1727
|
if (doc) {
|
|
1438
1728
|
log_collection_1.Logs.insertOne({
|
|
@@ -1468,10 +1758,16 @@ var Collection = /** @class */ (function () {
|
|
|
1468
1758
|
else {
|
|
1469
1759
|
resolve(0);
|
|
1470
1760
|
}
|
|
1471
|
-
}, function (err) {
|
|
1761
|
+
}, function (err) {
|
|
1762
|
+
monitor_18.finish();
|
|
1763
|
+
console.log(new Date(), 'Error Find One And Update', _this.collectionName, filter, update, options, err);
|
|
1764
|
+
reject(err);
|
|
1765
|
+
});
|
|
1472
1766
|
}
|
|
1473
1767
|
else {
|
|
1768
|
+
monitor_19 = new monitor_manager_1.MonitorMongo('updateOne', this.collectionName, JSON.stringify([filter, update, options]));
|
|
1474
1769
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName).updateOne(filter, update, options).then(function (res) {
|
|
1770
|
+
monitor_19.finish();
|
|
1475
1771
|
if (res.acknowledged) {
|
|
1476
1772
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1477
1773
|
resolve(res.modifiedCount);
|
|
@@ -1479,7 +1775,11 @@ var Collection = /** @class */ (function () {
|
|
|
1479
1775
|
else {
|
|
1480
1776
|
reject(res.acknowledged);
|
|
1481
1777
|
}
|
|
1482
|
-
}, function (err) {
|
|
1778
|
+
}, function (err) {
|
|
1779
|
+
monitor_19.finish();
|
|
1780
|
+
console.log(new Date(), 'Error Update One', _this.collectionName, filter, update, options, err);
|
|
1781
|
+
reject(err);
|
|
1782
|
+
});
|
|
1483
1783
|
}
|
|
1484
1784
|
_a.label = 3;
|
|
1485
1785
|
case 3: return [2 /*return*/];
|