@resolveio/server-lib 12.0.33 → 12.0.35
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/collections/app-status.collection.d.ts +2 -2
- package/collections/app-status.collection.js +1 -1
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.d.ts +2 -2
- package/collections/app-version.collection.js +1 -1
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.d.ts +2 -2
- package/collections/counter.collection.js +1 -1
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.d.ts +2 -2
- package/collections/cron-job-history.collection.js +1 -1
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.d.ts +2 -2
- package/collections/cron-job.collection.js +1 -1
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.d.ts +2 -2
- package/collections/email-history.collection.js +1 -1
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.d.ts +2 -2
- package/collections/email-verified.collection.js +1 -1
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.d.ts +2 -2
- package/collections/file.collection.js +1 -1
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.d.ts +2 -2
- package/collections/flag.collection.js +1 -1
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.d.ts +2 -2
- package/collections/log-method-latency.collection.js +1 -1
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.d.ts +2 -2
- package/collections/log-subscription.collection.js +1 -1
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.d.ts +2 -2
- package/collections/log.collection.js +1 -1
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.d.ts +2 -2
- package/collections/logged-in-users.collection.js +1 -1
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-response.collection.d.ts +2 -2
- package/collections/method-response.collection.js +1 -1
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.d.ts +2 -2
- package/collections/monitor-cpu.collection.js +1 -1
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-memory.collection.d.ts +2 -2
- package/collections/monitor-memory.collection.js +1 -1
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.d.ts +2 -2
- package/collections/monitor-mongo.collection.js +1 -1
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.d.ts +2 -2
- package/collections/notification.collection.js +1 -1
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.d.ts +2 -2
- package/collections/report-builder-dashboard-builder.collection.js +1 -1
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.d.ts +2 -2
- package/collections/report-builder-library.collection.js +1 -1
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.d.ts +3 -3
- package/collections/report-builder-report.collection.js +1 -1
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.d.ts +3 -3
- package/collections/user-group.collection.js +1 -1
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.d.ts +2 -2
- package/collections/user-guide.collection.js +1 -1
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.d.ts +3 -3
- package/collections/user.collection.js +1 -1
- package/collections/user.collection.js.map +1 -1
- package/managers/mongo.manager.d.ts +46 -31
- package/managers/mongo.manager.js +142 -143
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -1
- package/managers/subscription.manager.js.map +1 -1
- package/models/collection-document.model.d.ts +14 -2
- package/models/collection-document.model.js.map +1 -1
- package/package.json +1 -1
|
@@ -56,7 +56,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
|
56
56
|
return r;
|
|
57
57
|
};
|
|
58
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
-
exports.objectIdHexString = exports.
|
|
59
|
+
exports.objectIdHexString = exports.MongoManagerUserCollection = exports.MongoManagerCollection = exports.MongoManagerModel = exports.MongoManager = void 0;
|
|
60
60
|
var simpl_schema_1 = require("simpl-schema");
|
|
61
61
|
var mongodb_1 = require("mongodb");
|
|
62
62
|
var index_1 = require("../index");
|
|
@@ -299,21 +299,21 @@ var MongoManager = /** @class */ (function () {
|
|
|
299
299
|
return MongoManager;
|
|
300
300
|
}());
|
|
301
301
|
exports.MongoManager = MongoManager;
|
|
302
|
-
var
|
|
303
|
-
function
|
|
302
|
+
var MongoManagerModel = /** @class */ (function () {
|
|
303
|
+
function MongoManagerModel(options) {
|
|
304
304
|
this.collection_main = null;
|
|
305
305
|
this.collection_version = null;
|
|
306
306
|
if (options.collectionName === 'users') {
|
|
307
|
-
this.collection_main = new
|
|
307
|
+
this.collection_main = new MongoManagerUserCollection(options);
|
|
308
308
|
}
|
|
309
309
|
else {
|
|
310
|
-
this.collection_main = new
|
|
310
|
+
this.collection_main = new MongoManagerCollection(options);
|
|
311
311
|
}
|
|
312
312
|
if (options.useVersionCollection) {
|
|
313
313
|
this.collection_main.useVersions = true;
|
|
314
314
|
var versionSchema = common_1.deepCopy(options.schema);
|
|
315
|
-
versionSchema
|
|
316
|
-
versionSchema
|
|
315
|
+
versionSchema._id.type = 'Object';
|
|
316
|
+
versionSchema._id.blackbox = true;
|
|
317
317
|
var versionOptions = {
|
|
318
318
|
collectionName: options.collectionName + '.versions',
|
|
319
319
|
schema: versionSchema,
|
|
@@ -326,20 +326,20 @@ var Model = /** @class */ (function () {
|
|
|
326
326
|
collectionOptions: null
|
|
327
327
|
};
|
|
328
328
|
if (options.collectionName === 'users') {
|
|
329
|
-
this.collection_version = new
|
|
329
|
+
this.collection_version = new MongoManagerUserCollection(versionOptions);
|
|
330
330
|
}
|
|
331
331
|
else {
|
|
332
|
-
this.collection_version = new
|
|
332
|
+
this.collection_version = new MongoManagerCollection(versionOptions);
|
|
333
333
|
}
|
|
334
334
|
this.collection_version.createIndex({ '_id._id': 1, '_id.__v': 1 });
|
|
335
335
|
this.collection_main.versionCollection = options.collectionName + '.versions';
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
return
|
|
338
|
+
return MongoManagerModel;
|
|
339
339
|
}());
|
|
340
|
-
exports.
|
|
341
|
-
var
|
|
342
|
-
function
|
|
340
|
+
exports.MongoManagerModel = MongoManagerModel;
|
|
341
|
+
var MongoManagerCollection = /** @class */ (function () {
|
|
342
|
+
function MongoManagerCollection(options) {
|
|
343
343
|
var _this = this;
|
|
344
344
|
this.collectionName = '';
|
|
345
345
|
this.checkSchema = false;
|
|
@@ -369,7 +369,7 @@ var Collection = /** @class */ (function () {
|
|
|
369
369
|
}
|
|
370
370
|
}, 1);
|
|
371
371
|
}
|
|
372
|
-
|
|
372
|
+
MongoManagerCollection.prototype.aggregate = function (pipeline, options, skipCache) {
|
|
373
373
|
var _this = this;
|
|
374
374
|
if (skipCache === void 0) { skipCache = false; }
|
|
375
375
|
return new Promise(function (resolve, reject) {
|
|
@@ -411,7 +411,7 @@ var Collection = /** @class */ (function () {
|
|
|
411
411
|
}
|
|
412
412
|
});
|
|
413
413
|
};
|
|
414
|
-
|
|
414
|
+
MongoManagerCollection.prototype.aggregateCount = function (pipeline, options) {
|
|
415
415
|
var _this = this;
|
|
416
416
|
return new Promise(function (resolve, reject) {
|
|
417
417
|
index_1.ResolveIOServer.getMongoManager().addToQueue({
|
|
@@ -439,7 +439,7 @@ var Collection = /** @class */ (function () {
|
|
|
439
439
|
});
|
|
440
440
|
});
|
|
441
441
|
};
|
|
442
|
-
|
|
442
|
+
MongoManagerCollection.prototype.aggregateCursor = function (pipeline, options) {
|
|
443
443
|
var monitor = new monitor_manager_1.MonitorMongo('aggregateCursor', this.collectionName, JSON.stringify([pipeline, options]));
|
|
444
444
|
var cursor = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).aggregate(pipeline, options);
|
|
445
445
|
cursor.on('close', function (ev) {
|
|
@@ -448,7 +448,7 @@ var Collection = /** @class */ (function () {
|
|
|
448
448
|
});
|
|
449
449
|
return cursor;
|
|
450
450
|
};
|
|
451
|
-
|
|
451
|
+
MongoManagerCollection.prototype.aggregateStream = function (pipeline, options, streamOptions) {
|
|
452
452
|
var monitor = new monitor_manager_1.MonitorMongo('aggregateStream', this.collectionName, JSON.stringify([pipeline, options, streamOptions]));
|
|
453
453
|
var stream = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).aggregate(pipeline, options).stream(streamOptions);
|
|
454
454
|
stream.on('end', function (ev) {
|
|
@@ -457,7 +457,7 @@ var Collection = /** @class */ (function () {
|
|
|
457
457
|
});
|
|
458
458
|
return stream;
|
|
459
459
|
};
|
|
460
|
-
|
|
460
|
+
MongoManagerCollection.prototype.countDocuments = function (filter, options) {
|
|
461
461
|
var _this = this;
|
|
462
462
|
if (filter === void 0) { filter = {}; }
|
|
463
463
|
return new Promise(function (resolve, reject) {
|
|
@@ -473,14 +473,13 @@ var Collection = /** @class */ (function () {
|
|
|
473
473
|
});
|
|
474
474
|
};
|
|
475
475
|
//Helper Function (1 or Many) - Not Real Mongo Function
|
|
476
|
-
|
|
477
|
-
var docs = [];
|
|
476
|
+
MongoManagerCollection.prototype.create = function (f_docs, options) {
|
|
478
477
|
if (!Array.isArray(f_docs)) {
|
|
479
478
|
return this.insertOne(f_docs, options);
|
|
480
479
|
}
|
|
481
480
|
return this.insertMany(f_docs, options);
|
|
482
481
|
};
|
|
483
|
-
|
|
482
|
+
MongoManagerCollection.prototype.createIndex = function (fieldOrSpec, options) {
|
|
484
483
|
var _this = this;
|
|
485
484
|
return new Promise(function (resolve, reject) {
|
|
486
485
|
if (index_1.ResolveIOServer.getMainDB().collection(_this.collectionName, _this.collectionOptions)) {
|
|
@@ -496,7 +495,7 @@ var Collection = /** @class */ (function () {
|
|
|
496
495
|
}
|
|
497
496
|
});
|
|
498
497
|
};
|
|
499
|
-
|
|
498
|
+
MongoManagerCollection.prototype.createIndexes = function (indexSpecs, options) {
|
|
500
499
|
var _this = this;
|
|
501
500
|
return new Promise(function (resolve, reject) {
|
|
502
501
|
if (index_1.ResolveIOServer.getMainDB().collection(_this.collectionName, _this.collectionOptions)) {
|
|
@@ -512,7 +511,7 @@ var Collection = /** @class */ (function () {
|
|
|
512
511
|
}
|
|
513
512
|
});
|
|
514
513
|
};
|
|
515
|
-
|
|
514
|
+
MongoManagerCollection.prototype.deleteMany = function (filter, options, bypassLogs) {
|
|
516
515
|
var _this = this;
|
|
517
516
|
if (filter === void 0) { filter = {}; }
|
|
518
517
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
@@ -532,7 +531,7 @@ var Collection = /** @class */ (function () {
|
|
|
532
531
|
_id: objectIdHexString(),
|
|
533
532
|
type: 'document',
|
|
534
533
|
collection: this.collectionName,
|
|
535
|
-
id_document: doc
|
|
534
|
+
id_document: doc._id,
|
|
536
535
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, options])) < 200000 ? JSON.stringify([doc, filter, options], null, 2) : 'Too Big',
|
|
537
536
|
method: 'deleteMany',
|
|
538
537
|
id_user: '',
|
|
@@ -542,9 +541,9 @@ var Collection = /** @class */ (function () {
|
|
|
542
541
|
});
|
|
543
542
|
if (this.useVersions) {
|
|
544
543
|
versionDoc = common_1.deepCopy(doc);
|
|
545
|
-
versionDoc
|
|
546
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc
|
|
547
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc
|
|
544
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
545
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v, xx: 1 } }, versionDoc, { upsert: true });
|
|
546
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc._id }, { '_id.__v': { $lt: doc.__v - 1 } }] });
|
|
548
547
|
}
|
|
549
548
|
}
|
|
550
549
|
_a.label = 2;
|
|
@@ -569,7 +568,7 @@ var Collection = /** @class */ (function () {
|
|
|
569
568
|
});
|
|
570
569
|
}); });
|
|
571
570
|
};
|
|
572
|
-
|
|
571
|
+
MongoManagerCollection.prototype.deleteOne = function (filter, options, bypassLogs) {
|
|
573
572
|
var _this = this;
|
|
574
573
|
if (filter === void 0) { filter = {}; }
|
|
575
574
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
@@ -590,7 +589,7 @@ var Collection = /** @class */ (function () {
|
|
|
590
589
|
_id: objectIdHexString(),
|
|
591
590
|
type: 'document',
|
|
592
591
|
collection: this.collectionName,
|
|
593
|
-
id_document: doc
|
|
592
|
+
id_document: doc._id,
|
|
594
593
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, options])) < 200000 ? JSON.stringify([doc, filter, options], null, 2) : 'Too Big',
|
|
595
594
|
method: 'deleteOne',
|
|
596
595
|
id_user: '',
|
|
@@ -601,9 +600,9 @@ var Collection = /** @class */ (function () {
|
|
|
601
600
|
}
|
|
602
601
|
if (this.useVersions) {
|
|
603
602
|
versionDoc = common_1.deepCopy(doc);
|
|
604
|
-
versionDoc
|
|
605
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc
|
|
606
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc
|
|
603
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
604
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
605
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc._id }, { '_id.__v': { $lt: doc.__v - 1 } }] });
|
|
607
606
|
}
|
|
608
607
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(this.collectionName);
|
|
609
608
|
resolve(1);
|
|
@@ -640,7 +639,7 @@ var Collection = /** @class */ (function () {
|
|
|
640
639
|
});
|
|
641
640
|
}); });
|
|
642
641
|
};
|
|
643
|
-
|
|
642
|
+
MongoManagerCollection.prototype.distinct = function (key, filter, options) {
|
|
644
643
|
var _this = this;
|
|
645
644
|
return new Promise(function (resolve, reject) {
|
|
646
645
|
var monitor = new monitor_manager_1.MonitorMongo('distinct', _this.collectionName, JSON.stringify([key, filter, options]));
|
|
@@ -654,7 +653,7 @@ var Collection = /** @class */ (function () {
|
|
|
654
653
|
});
|
|
655
654
|
});
|
|
656
655
|
};
|
|
657
|
-
|
|
656
|
+
MongoManagerCollection.prototype.drop = function (options) {
|
|
658
657
|
var _this = this;
|
|
659
658
|
return new Promise(function (resolve, reject) {
|
|
660
659
|
var monitor = new monitor_manager_1.MonitorMongo('drop', _this.collectionName, JSON.stringify([options]));
|
|
@@ -668,7 +667,7 @@ var Collection = /** @class */ (function () {
|
|
|
668
667
|
});
|
|
669
668
|
});
|
|
670
669
|
};
|
|
671
|
-
|
|
670
|
+
MongoManagerCollection.prototype.dropIndex = function (indexName, options) {
|
|
672
671
|
var _this = this;
|
|
673
672
|
return new Promise(function (resolve, reject) {
|
|
674
673
|
var monitor = new monitor_manager_1.MonitorMongo('dropIndex', _this.collectionName, JSON.stringify([indexName, options]));
|
|
@@ -682,7 +681,7 @@ var Collection = /** @class */ (function () {
|
|
|
682
681
|
});
|
|
683
682
|
});
|
|
684
683
|
};
|
|
685
|
-
|
|
684
|
+
MongoManagerCollection.prototype.dropIndexes = function (options) {
|
|
686
685
|
var _this = this;
|
|
687
686
|
return new Promise(function (resolve, reject) {
|
|
688
687
|
var monitor = new monitor_manager_1.MonitorMongo('dropIndexes', _this.collectionName, JSON.stringify([options]));
|
|
@@ -696,7 +695,7 @@ var Collection = /** @class */ (function () {
|
|
|
696
695
|
});
|
|
697
696
|
});
|
|
698
697
|
};
|
|
699
|
-
|
|
698
|
+
MongoManagerCollection.prototype.find = function (filter, options, skipCache) {
|
|
700
699
|
var _this = this;
|
|
701
700
|
if (filter === void 0) { filter = {}; }
|
|
702
701
|
if (skipCache === void 0) { skipCache = false; }
|
|
@@ -742,7 +741,7 @@ var Collection = /** @class */ (function () {
|
|
|
742
741
|
});
|
|
743
742
|
}); });
|
|
744
743
|
};
|
|
745
|
-
|
|
744
|
+
MongoManagerCollection.prototype.findById = function (id, options) {
|
|
746
745
|
var _this = this;
|
|
747
746
|
return new Promise(function (resolve, reject) {
|
|
748
747
|
var monitor = new monitor_manager_1.MonitorMongo('findById', _this.collectionName, JSON.stringify([{ _id: id }, options]));
|
|
@@ -756,7 +755,7 @@ var Collection = /** @class */ (function () {
|
|
|
756
755
|
});
|
|
757
756
|
});
|
|
758
757
|
};
|
|
759
|
-
|
|
758
|
+
MongoManagerCollection.prototype.findCount = function (filter, options) {
|
|
760
759
|
var _this = this;
|
|
761
760
|
if (filter === void 0) { filter = {}; }
|
|
762
761
|
return new Promise(function (resolve, reject) {
|
|
@@ -771,7 +770,7 @@ var Collection = /** @class */ (function () {
|
|
|
771
770
|
});
|
|
772
771
|
});
|
|
773
772
|
};
|
|
774
|
-
|
|
773
|
+
MongoManagerCollection.prototype.findCursor = function (filter, options) {
|
|
775
774
|
if (filter === void 0) { filter = {}; }
|
|
776
775
|
var monitor = new monitor_manager_1.MonitorMongo('findCursor', this.collectionName, JSON.stringify([filter, options]));
|
|
777
776
|
var cursor = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).find(filter, options);
|
|
@@ -781,7 +780,7 @@ var Collection = /** @class */ (function () {
|
|
|
781
780
|
});
|
|
782
781
|
return cursor;
|
|
783
782
|
};
|
|
784
|
-
|
|
783
|
+
MongoManagerCollection.prototype.findStream = function (filter, options, streamOptions) {
|
|
785
784
|
if (filter === void 0) { filter = {}; }
|
|
786
785
|
var monitor = new monitor_manager_1.MonitorMongo('findStream', this.collectionName, JSON.stringify([filter, options, streamOptions]));
|
|
787
786
|
var stream = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).find(filter, options).stream(streamOptions);
|
|
@@ -791,7 +790,7 @@ var Collection = /** @class */ (function () {
|
|
|
791
790
|
});
|
|
792
791
|
return stream;
|
|
793
792
|
};
|
|
794
|
-
|
|
793
|
+
MongoManagerCollection.prototype.findOne = function (filter, options, skipCache) {
|
|
795
794
|
var _this = this;
|
|
796
795
|
if (filter === void 0) { filter = {}; }
|
|
797
796
|
if (skipCache === void 0) { skipCache = false; }
|
|
@@ -832,7 +831,7 @@ var Collection = /** @class */ (function () {
|
|
|
832
831
|
}
|
|
833
832
|
});
|
|
834
833
|
};
|
|
835
|
-
|
|
834
|
+
MongoManagerCollection.prototype.findOneAndDelete = function (filter, options, bypassLogs) {
|
|
836
835
|
var _this = this;
|
|
837
836
|
if (filter === void 0) { filter = {}; }
|
|
838
837
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
@@ -850,7 +849,7 @@ var Collection = /** @class */ (function () {
|
|
|
850
849
|
_id: objectIdHexString(),
|
|
851
850
|
type: 'document',
|
|
852
851
|
collection: _this.collectionName,
|
|
853
|
-
id_document: doc
|
|
852
|
+
id_document: doc._id,
|
|
854
853
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, options])) < 200000 ? JSON.stringify([doc, filter, options], null, 2) : 'Too Big',
|
|
855
854
|
method: 'findOneAndDelete',
|
|
856
855
|
id_user: '',
|
|
@@ -861,8 +860,8 @@ var Collection = /** @class */ (function () {
|
|
|
861
860
|
}
|
|
862
861
|
if (_this.useVersions) {
|
|
863
862
|
var versionDoc = common_1.deepCopy(doc);
|
|
864
|
-
versionDoc
|
|
865
|
-
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc
|
|
863
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
864
|
+
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
866
865
|
}
|
|
867
866
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
868
867
|
resolve(doc);
|
|
@@ -879,7 +878,7 @@ var Collection = /** @class */ (function () {
|
|
|
879
878
|
});
|
|
880
879
|
}); });
|
|
881
880
|
};
|
|
882
|
-
|
|
881
|
+
MongoManagerCollection.prototype.findOneAndReplace = function (filter, replacement, options, bypassLogs, bypassCheckSchema) {
|
|
883
882
|
var _this = this;
|
|
884
883
|
if (filter === void 0) { filter = {}; }
|
|
885
884
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
@@ -900,17 +899,17 @@ var Collection = /** @class */ (function () {
|
|
|
900
899
|
}
|
|
901
900
|
date = new Date();
|
|
902
901
|
if (this.timestamps) {
|
|
903
|
-
replacement
|
|
902
|
+
replacement.updatedAt = date;
|
|
904
903
|
}
|
|
905
904
|
if (options && options.upsert) {
|
|
906
|
-
if (!replacement
|
|
907
|
-
replacement
|
|
905
|
+
if (!replacement._id) {
|
|
906
|
+
replacement._id = objectIdHexString();
|
|
908
907
|
}
|
|
909
908
|
if (this.useVersions) {
|
|
910
|
-
replacement
|
|
909
|
+
replacement.__v = 0;
|
|
911
910
|
}
|
|
912
|
-
if (this.timestamps && !replacement
|
|
913
|
-
replacement
|
|
911
|
+
if (this.timestamps && !replacement.createdAt) {
|
|
912
|
+
replacement.createdAt = date;
|
|
914
913
|
}
|
|
915
914
|
}
|
|
916
915
|
monitor = new monitor_manager_1.MonitorMongo('findOneAndReplace', this.collectionName, JSON.stringify([filter, replacement, options]));
|
|
@@ -923,7 +922,7 @@ var Collection = /** @class */ (function () {
|
|
|
923
922
|
_id: objectIdHexString(),
|
|
924
923
|
type: 'document',
|
|
925
924
|
collection: _this.collectionName,
|
|
926
|
-
id_document: doc
|
|
925
|
+
id_document: doc._id,
|
|
927
926
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, replacement, options])) < 200000 ? JSON.stringify([doc, filter, replacement, options], null, 2) : 'Too Big',
|
|
928
927
|
method: 'findOneAndReplace',
|
|
929
928
|
id_user: '',
|
|
@@ -934,8 +933,8 @@ var Collection = /** @class */ (function () {
|
|
|
934
933
|
}
|
|
935
934
|
if (_this.useVersions) {
|
|
936
935
|
var versionDoc = common_1.deepCopy(doc);
|
|
937
|
-
versionDoc
|
|
938
|
-
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc
|
|
936
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
937
|
+
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
939
938
|
}
|
|
940
939
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
941
940
|
resolve(doc);
|
|
@@ -952,7 +951,7 @@ var Collection = /** @class */ (function () {
|
|
|
952
951
|
});
|
|
953
952
|
}); });
|
|
954
953
|
};
|
|
955
|
-
|
|
954
|
+
MongoManagerCollection.prototype.findOneAndUpdate = function (filter, update, options, bypassLogs, bypassCheckSchema) {
|
|
956
955
|
var _this = this;
|
|
957
956
|
if (filter === void 0) { filter = {}; }
|
|
958
957
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
@@ -973,11 +972,11 @@ var Collection = /** @class */ (function () {
|
|
|
973
972
|
}
|
|
974
973
|
if (this.timestamps) {
|
|
975
974
|
date = new Date();
|
|
976
|
-
if (!update
|
|
977
|
-
update
|
|
975
|
+
if (!update.$set) {
|
|
976
|
+
update.$set = { updatedAt: date };
|
|
978
977
|
}
|
|
979
978
|
else {
|
|
980
|
-
update
|
|
979
|
+
update.$set.updatedAt = date;
|
|
981
980
|
}
|
|
982
981
|
}
|
|
983
982
|
if (options && options.upsert) {
|
|
@@ -1013,7 +1012,7 @@ var Collection = /** @class */ (function () {
|
|
|
1013
1012
|
_id: objectIdHexString(),
|
|
1014
1013
|
type: 'document',
|
|
1015
1014
|
collection: _this.collectionName,
|
|
1016
|
-
id_document: doc
|
|
1015
|
+
id_document: doc._id,
|
|
1017
1016
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, update, options])) < 200000 ? JSON.stringify([doc, filter, update, options], null, 2) : 'Too Big',
|
|
1018
1017
|
method: 'findOneAndUpdate',
|
|
1019
1018
|
id_user: '',
|
|
@@ -1024,8 +1023,8 @@ var Collection = /** @class */ (function () {
|
|
|
1024
1023
|
}
|
|
1025
1024
|
if (_this.useVersions) {
|
|
1026
1025
|
var versionDoc = common_1.deepCopy(doc);
|
|
1027
|
-
versionDoc
|
|
1028
|
-
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc
|
|
1026
|
+
versionDoc._id = { _id: doc._id, __v: doc._id };
|
|
1027
|
+
index_1.ResolveIOServer.getMongoManager().collection(_this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
1029
1028
|
}
|
|
1030
1029
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(_this.collectionName);
|
|
1031
1030
|
resolve(doc);
|
|
@@ -1042,7 +1041,7 @@ var Collection = /** @class */ (function () {
|
|
|
1042
1041
|
});
|
|
1043
1042
|
}); });
|
|
1044
1043
|
};
|
|
1045
|
-
|
|
1044
|
+
MongoManagerCollection.prototype.indexes = function (options) {
|
|
1046
1045
|
var _this = this;
|
|
1047
1046
|
return new Promise(function (resolve, reject) {
|
|
1048
1047
|
var monitor = new monitor_manager_1.MonitorMongo('indexes', _this.collectionName, JSON.stringify([options]));
|
|
@@ -1056,7 +1055,7 @@ var Collection = /** @class */ (function () {
|
|
|
1056
1055
|
});
|
|
1057
1056
|
});
|
|
1058
1057
|
};
|
|
1059
|
-
|
|
1058
|
+
MongoManagerCollection.prototype.indexExists = function (indexes, options) {
|
|
1060
1059
|
var _this = this;
|
|
1061
1060
|
return new Promise(function (resolve, reject) {
|
|
1062
1061
|
var monitor = new monitor_manager_1.MonitorMongo('indexExists', _this.collectionName, JSON.stringify([indexes, options]));
|
|
@@ -1070,7 +1069,7 @@ var Collection = /** @class */ (function () {
|
|
|
1070
1069
|
});
|
|
1071
1070
|
});
|
|
1072
1071
|
};
|
|
1073
|
-
|
|
1072
|
+
MongoManagerCollection.prototype.insertMany = function (docs, options, bypassLogs, bypassCheckSchema) {
|
|
1074
1073
|
var _this = this;
|
|
1075
1074
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1076
1075
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
@@ -1100,20 +1099,20 @@ var Collection = /** @class */ (function () {
|
|
|
1100
1099
|
validDocs = this.checkSchema ? docs.filter(function (a, idx) { return validationResults[idx]; }) : docs;
|
|
1101
1100
|
for (i = 0; i < validDocs.length; i++) {
|
|
1102
1101
|
doc = validDocs[i];
|
|
1103
|
-
if (!doc
|
|
1104
|
-
doc
|
|
1102
|
+
if (!doc._id) {
|
|
1103
|
+
doc._id = objectIdHexString();
|
|
1105
1104
|
}
|
|
1106
1105
|
if (this.timestamps) {
|
|
1107
1106
|
date = new Date();
|
|
1108
|
-
doc
|
|
1109
|
-
doc
|
|
1107
|
+
doc.createdAt = date;
|
|
1108
|
+
doc.updatedAt = date;
|
|
1110
1109
|
}
|
|
1111
1110
|
if (this.createLogs && !bypassLogs) {
|
|
1112
1111
|
log_collection_1.Logs.insertOne({
|
|
1113
1112
|
_id: objectIdHexString(),
|
|
1114
1113
|
type: 'document',
|
|
1115
1114
|
collection: this.collectionName,
|
|
1116
|
-
id_document: doc
|
|
1115
|
+
id_document: doc._id,
|
|
1117
1116
|
payload: common_1.getBinarySize(JSON.stringify([doc, options])) < 200000 ? JSON.stringify([doc, options], null, 2) : 'Too Big',
|
|
1118
1117
|
method: 'insertMany',
|
|
1119
1118
|
id_user: '',
|
|
@@ -1144,7 +1143,7 @@ var Collection = /** @class */ (function () {
|
|
|
1144
1143
|
});
|
|
1145
1144
|
}); });
|
|
1146
1145
|
};
|
|
1147
|
-
|
|
1146
|
+
MongoManagerCollection.prototype.insertOne = function (doc, options, bypassLogs, bypassCheckSchema) {
|
|
1148
1147
|
var _this = this;
|
|
1149
1148
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1150
1149
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
@@ -1152,8 +1151,8 @@ var Collection = /** @class */ (function () {
|
|
|
1152
1151
|
var validation, isValid, date, monitor;
|
|
1153
1152
|
var _this = this;
|
|
1154
1153
|
return __generator(this, function (_a) {
|
|
1155
|
-
if (!doc
|
|
1156
|
-
doc
|
|
1154
|
+
if (!doc._id) {
|
|
1155
|
+
doc._id = objectIdHexString();
|
|
1157
1156
|
}
|
|
1158
1157
|
if (this.checkSchema && !bypassCheckSchema) {
|
|
1159
1158
|
validation = this.simplschema.newContext();
|
|
@@ -1167,15 +1166,15 @@ var Collection = /** @class */ (function () {
|
|
|
1167
1166
|
}
|
|
1168
1167
|
if (this.timestamps) {
|
|
1169
1168
|
date = new Date();
|
|
1170
|
-
doc
|
|
1171
|
-
doc
|
|
1169
|
+
doc.createdAt = date;
|
|
1170
|
+
doc.updatedAt = date;
|
|
1172
1171
|
}
|
|
1173
1172
|
if (this.createLogs && !bypassLogs) {
|
|
1174
1173
|
log_collection_1.Logs.insertOne({
|
|
1175
1174
|
_id: objectIdHexString(),
|
|
1176
1175
|
type: 'document',
|
|
1177
1176
|
collection: this.collectionName,
|
|
1178
|
-
id_document: doc
|
|
1177
|
+
id_document: doc._id,
|
|
1179
1178
|
payload: common_1.getBinarySize(JSON.stringify([doc, options])) < 200000 ? JSON.stringify([doc, options], null, 2) : 'Too Big',
|
|
1180
1179
|
method: 'insertOne',
|
|
1181
1180
|
id_user: '',
|
|
@@ -1185,7 +1184,7 @@ var Collection = /** @class */ (function () {
|
|
|
1185
1184
|
});
|
|
1186
1185
|
}
|
|
1187
1186
|
if (this.useVersions && !doc.hasOwnProperty('__v')) {
|
|
1188
|
-
doc
|
|
1187
|
+
doc.__v = 0;
|
|
1189
1188
|
}
|
|
1190
1189
|
monitor = new monitor_manager_1.MonitorMongo('insertOne', this.collectionName, JSON.stringify([doc, options]));
|
|
1191
1190
|
index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).insertOne(doc, options).then(function (res) {
|
|
@@ -1206,7 +1205,7 @@ var Collection = /** @class */ (function () {
|
|
|
1206
1205
|
});
|
|
1207
1206
|
}); });
|
|
1208
1207
|
};
|
|
1209
|
-
|
|
1208
|
+
MongoManagerCollection.prototype.listIndexes = function (options) {
|
|
1210
1209
|
var monitor = new monitor_manager_1.MonitorMongo('listIndexes', this.collectionName, JSON.stringify([options]));
|
|
1211
1210
|
var cursor = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).listIndexes(options);
|
|
1212
1211
|
cursor.on('close', function (ev) {
|
|
@@ -1215,7 +1214,7 @@ var Collection = /** @class */ (function () {
|
|
|
1215
1214
|
});
|
|
1216
1215
|
return cursor;
|
|
1217
1216
|
};
|
|
1218
|
-
|
|
1217
|
+
MongoManagerCollection.prototype.rename = function (newName, options) {
|
|
1219
1218
|
var _this = this;
|
|
1220
1219
|
return new Promise(function (resolve, reject) {
|
|
1221
1220
|
var monitor = new monitor_manager_1.MonitorMongo('rename', _this.collectionName, JSON.stringify([newName, options]));
|
|
@@ -1229,7 +1228,7 @@ var Collection = /** @class */ (function () {
|
|
|
1229
1228
|
});
|
|
1230
1229
|
});
|
|
1231
1230
|
};
|
|
1232
|
-
|
|
1231
|
+
MongoManagerCollection.prototype.replaceOne = function (filter, replacement, options, bypassLogs, bypassCheckSchema, doc) {
|
|
1233
1232
|
var _this = this;
|
|
1234
1233
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1235
1234
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
@@ -1252,7 +1251,7 @@ var Collection = /** @class */ (function () {
|
|
|
1252
1251
|
}
|
|
1253
1252
|
date = new Date();
|
|
1254
1253
|
if (this.timestamps) {
|
|
1255
|
-
replacement
|
|
1254
|
+
replacement.updatedAt = date;
|
|
1256
1255
|
}
|
|
1257
1256
|
if (!this.useVersions) return [3 /*break*/, 8];
|
|
1258
1257
|
if (!!doc) return [3 /*break*/, 2];
|
|
@@ -1262,23 +1261,23 @@ var Collection = /** @class */ (function () {
|
|
|
1262
1261
|
_a.label = 2;
|
|
1263
1262
|
case 2:
|
|
1264
1263
|
if (!doc) return [3 /*break*/, 6];
|
|
1265
|
-
if (this.timestamps && !replacement
|
|
1266
|
-
replacement
|
|
1264
|
+
if (this.timestamps && !replacement.createdAt && doc.createdAt) {
|
|
1265
|
+
replacement.createdAt = doc.createdAt;
|
|
1267
1266
|
}
|
|
1268
|
-
if (!(doc
|
|
1269
|
-
replacement
|
|
1267
|
+
if (!(doc.__v === replacement.__v)) return [3 /*break*/, 3];
|
|
1268
|
+
replacement.__v += 1;
|
|
1270
1269
|
versionDoc = common_1.deepCopy(doc);
|
|
1271
|
-
versionDoc
|
|
1272
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc
|
|
1273
|
-
if (doc
|
|
1274
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc
|
|
1270
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
1271
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
1272
|
+
if (doc.__v >= 4) {
|
|
1273
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc._id }, { '_id.__v': { $lt: doc.__v - 4 } }] });
|
|
1275
1274
|
}
|
|
1276
1275
|
if (this.createLogs && !bypassLogs) {
|
|
1277
1276
|
log_collection_1.Logs.insertOne({
|
|
1278
1277
|
_id: objectIdHexString(),
|
|
1279
1278
|
type: 'document',
|
|
1280
1279
|
collection: this.collectionName,
|
|
1281
|
-
id_document: doc
|
|
1280
|
+
id_document: doc._id,
|
|
1282
1281
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, replacement, options])) < 200000 ? JSON.stringify([doc, filter, replacement, options], null, 2) : 'Too Big',
|
|
1283
1282
|
method: 'replaceOne',
|
|
1284
1283
|
id_user: '',
|
|
@@ -1304,21 +1303,21 @@ var Collection = /** @class */ (function () {
|
|
|
1304
1303
|
});
|
|
1305
1304
|
return [3 /*break*/, 5];
|
|
1306
1305
|
case 3:
|
|
1307
|
-
console.log('invalid version - ' + this.collectionName, doc
|
|
1306
|
+
console.log('invalid version - ' + this.collectionName, doc.__v, replacement.__v);
|
|
1308
1307
|
return [4 /*yield*/, index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).findOne({
|
|
1309
1308
|
_id: {
|
|
1310
|
-
_id: doc
|
|
1311
|
-
__v: replacement
|
|
1309
|
+
_id: doc._id,
|
|
1310
|
+
__v: replacement.__v
|
|
1312
1311
|
}
|
|
1313
1312
|
}, null, true)];
|
|
1314
1313
|
case 4:
|
|
1315
1314
|
prevDoc = _a.sent();
|
|
1316
1315
|
if (prevDoc) {
|
|
1317
|
-
docId = doc
|
|
1318
|
-
docVersion = doc
|
|
1316
|
+
docId = doc._id;
|
|
1317
|
+
docVersion = doc.__v;
|
|
1319
1318
|
updatedDoc_1 = common_1.getMongoMergeUpdatedDoc(replacement, doc, prevDoc);
|
|
1320
|
-
updatedDoc_1
|
|
1321
|
-
updatedDoc_1
|
|
1319
|
+
updatedDoc_1._id = docId;
|
|
1320
|
+
updatedDoc_1.__v = docVersion + 1;
|
|
1322
1321
|
if (this.createLogs && !bypassLogs) {
|
|
1323
1322
|
log_collection_1.Logs.insertOne({
|
|
1324
1323
|
_id: objectIdHexString(),
|
|
@@ -1350,25 +1349,25 @@ var Collection = /** @class */ (function () {
|
|
|
1350
1349
|
});
|
|
1351
1350
|
}
|
|
1352
1351
|
else {
|
|
1353
|
-
reject('Invalid Version And Could Not Find History - DB: ' + doc
|
|
1352
|
+
reject('Invalid Version And Could Not Find History - DB: ' + doc.__v + ', Trying to update with :' + replacement.__v);
|
|
1354
1353
|
}
|
|
1355
1354
|
_a.label = 5;
|
|
1356
1355
|
case 5: return [3 /*break*/, 7];
|
|
1357
1356
|
case 6:
|
|
1358
1357
|
if (options && options.upsert) {
|
|
1359
1358
|
if (this.timestamps) {
|
|
1360
|
-
replacement
|
|
1359
|
+
replacement.createdAt = date;
|
|
1361
1360
|
}
|
|
1362
|
-
if (!replacement
|
|
1363
|
-
replacement
|
|
1361
|
+
if (!replacement._id) {
|
|
1362
|
+
replacement._id = objectIdHexString();
|
|
1364
1363
|
}
|
|
1365
|
-
replacement
|
|
1364
|
+
replacement.__v = 0;
|
|
1366
1365
|
if (this.createLogs && !bypassLogs) {
|
|
1367
1366
|
log_collection_1.Logs.insertOne({
|
|
1368
1367
|
_id: objectIdHexString(),
|
|
1369
1368
|
type: 'document',
|
|
1370
1369
|
collection: this.collectionName,
|
|
1371
|
-
id_document: replacement
|
|
1370
|
+
id_document: replacement._id,
|
|
1372
1371
|
payload: common_1.getBinarySize(JSON.stringify(['upsert', filter, replacement, options])) < 200000 ? JSON.stringify(['upsert', filter, replacement, options], null, 2) : 'Too Big',
|
|
1373
1372
|
method: 'replaceOne',
|
|
1374
1373
|
id_user: '',
|
|
@@ -1400,13 +1399,13 @@ var Collection = /** @class */ (function () {
|
|
|
1400
1399
|
case 7: return [3 /*break*/, 9];
|
|
1401
1400
|
case 8:
|
|
1402
1401
|
if (options && options.upsert) {
|
|
1403
|
-
if (this.timestamps && !replacement
|
|
1404
|
-
replacement
|
|
1402
|
+
if (this.timestamps && !replacement.createdAt) {
|
|
1403
|
+
replacement.createdAt = date;
|
|
1405
1404
|
}
|
|
1406
|
-
if (!replacement
|
|
1407
|
-
replacement
|
|
1405
|
+
if (!replacement._id) {
|
|
1406
|
+
replacement._id = objectIdHexString();
|
|
1408
1407
|
}
|
|
1409
|
-
replacement
|
|
1408
|
+
replacement.__v = 0;
|
|
1410
1409
|
}
|
|
1411
1410
|
if (this.createLogs && !bypassLogs) {
|
|
1412
1411
|
if (!options) {
|
|
@@ -1438,7 +1437,7 @@ var Collection = /** @class */ (function () {
|
|
|
1438
1437
|
_id: objectIdHexString(),
|
|
1439
1438
|
type: 'document',
|
|
1440
1439
|
collection: _this.collectionName,
|
|
1441
|
-
id_document: replacement
|
|
1440
|
+
id_document: replacement._id,
|
|
1442
1441
|
payload: common_1.getBinarySize(JSON.stringify(['upsert', filter, replacement, options])) < 200000 ? JSON.stringify(['upsert', filter, replacement, options], null, 2) : 'Too Big',
|
|
1443
1442
|
method: 'replaceOne',
|
|
1444
1443
|
id_user: '',
|
|
@@ -1478,7 +1477,7 @@ var Collection = /** @class */ (function () {
|
|
|
1478
1477
|
});
|
|
1479
1478
|
}); });
|
|
1480
1479
|
};
|
|
1481
|
-
|
|
1480
|
+
MongoManagerCollection.prototype.stats = function (options) {
|
|
1482
1481
|
var _this = this;
|
|
1483
1482
|
return new Promise(function (resolve, reject) {
|
|
1484
1483
|
var monitor = new monitor_manager_1.MonitorMongo('stats', _this.collectionName, JSON.stringify([options]));
|
|
@@ -1492,7 +1491,7 @@ var Collection = /** @class */ (function () {
|
|
|
1492
1491
|
});
|
|
1493
1492
|
});
|
|
1494
1493
|
};
|
|
1495
|
-
|
|
1494
|
+
MongoManagerCollection.prototype.updateMany = function (filter, update, options, bypassLogs, bypassCheckSchema, bypassVersions) {
|
|
1496
1495
|
var _this = this;
|
|
1497
1496
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1498
1497
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
@@ -1509,7 +1508,7 @@ var Collection = /** @class */ (function () {
|
|
|
1509
1508
|
update.$set = { updatedAt: date };
|
|
1510
1509
|
}
|
|
1511
1510
|
else {
|
|
1512
|
-
update.$set
|
|
1511
|
+
(update.$set).updatedAt = date;
|
|
1513
1512
|
}
|
|
1514
1513
|
}
|
|
1515
1514
|
if (this.checkSchema && !bypassCheckSchema) {
|
|
@@ -1533,7 +1532,7 @@ var Collection = /** @class */ (function () {
|
|
|
1533
1532
|
_id: objectIdHexString(),
|
|
1534
1533
|
type: 'document',
|
|
1535
1534
|
collection: this.collectionName,
|
|
1536
|
-
id_document: doc
|
|
1535
|
+
id_document: doc._id,
|
|
1537
1536
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, update, options])) < 200000 ? JSON.stringify([doc, filter, update, options], null, 2) : 'Too Big',
|
|
1538
1537
|
method: 'updateMany',
|
|
1539
1538
|
id_user: '',
|
|
@@ -1544,10 +1543,10 @@ var Collection = /** @class */ (function () {
|
|
|
1544
1543
|
}
|
|
1545
1544
|
if (this.useVersions) {
|
|
1546
1545
|
versionDoc = common_1.deepCopy(doc);
|
|
1547
|
-
versionDoc
|
|
1548
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc
|
|
1549
|
-
if (doc
|
|
1550
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc
|
|
1546
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
1547
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
1548
|
+
if (doc.__v >= 4) {
|
|
1549
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc._id }, { '_id.__v': { $lt: doc.__v - 4 } }] });
|
|
1551
1550
|
}
|
|
1552
1551
|
if (!objectContainsPropertyDeep(update, '__v')) {
|
|
1553
1552
|
if (!update.$inc) {
|
|
@@ -1581,7 +1580,7 @@ var Collection = /** @class */ (function () {
|
|
|
1581
1580
|
});
|
|
1582
1581
|
}); });
|
|
1583
1582
|
};
|
|
1584
|
-
|
|
1583
|
+
MongoManagerCollection.prototype.updateOne = function (filter, update, options, bypassLogs, bypassCheckSchema) {
|
|
1585
1584
|
var _this = this;
|
|
1586
1585
|
if (bypassLogs === void 0) { bypassLogs = false; }
|
|
1587
1586
|
if (bypassCheckSchema === void 0) { bypassCheckSchema = false; }
|
|
@@ -1607,7 +1606,7 @@ var Collection = /** @class */ (function () {
|
|
|
1607
1606
|
update.$set = { updatedAt: date };
|
|
1608
1607
|
}
|
|
1609
1608
|
else {
|
|
1610
|
-
update.$set
|
|
1609
|
+
update.$set.updatedAt = date;
|
|
1611
1610
|
}
|
|
1612
1611
|
}
|
|
1613
1612
|
if (!this.useVersions) return [3 /*break*/, 2];
|
|
@@ -1620,7 +1619,7 @@ var Collection = /** @class */ (function () {
|
|
|
1620
1619
|
_id: objectIdHexString(),
|
|
1621
1620
|
type: 'document',
|
|
1622
1621
|
collection: this.collectionName,
|
|
1623
|
-
id_document: doc
|
|
1622
|
+
id_document: doc._id,
|
|
1624
1623
|
payload: common_1.getBinarySize(JSON.stringify([doc, filter, update, options])) < 200000 ? JSON.stringify([doc, filter, update, options], null, 2) : 'Too Big',
|
|
1625
1624
|
method: 'updateOne',
|
|
1626
1625
|
id_user: '',
|
|
@@ -1630,10 +1629,10 @@ var Collection = /** @class */ (function () {
|
|
|
1630
1629
|
});
|
|
1631
1630
|
}
|
|
1632
1631
|
versionDoc = common_1.deepCopy(doc);
|
|
1633
|
-
versionDoc
|
|
1634
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc
|
|
1635
|
-
if (doc
|
|
1636
|
-
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc
|
|
1632
|
+
versionDoc._id = { _id: doc._id, __v: doc.__v };
|
|
1633
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).replaceOne({ _id: { _id: doc._id, __v: doc.__v } }, versionDoc, { upsert: true });
|
|
1634
|
+
if (doc.__v >= 4) {
|
|
1635
|
+
index_1.ResolveIOServer.getMongoManager().collection(this.versionCollection).deleteMany({ $and: [{ '_id._id': doc._id }, { '_id.__v': { $lt: doc.__v - 4 } }] });
|
|
1637
1636
|
}
|
|
1638
1637
|
if (!objectContainsPropertyDeep(update, '__v')) {
|
|
1639
1638
|
if (!update.$inc) {
|
|
@@ -1815,7 +1814,7 @@ var Collection = /** @class */ (function () {
|
|
|
1815
1814
|
});
|
|
1816
1815
|
}); });
|
|
1817
1816
|
};
|
|
1818
|
-
|
|
1817
|
+
MongoManagerCollection.prototype.watchCollection = function (pipeline, options) {
|
|
1819
1818
|
var _this = this;
|
|
1820
1819
|
if (pipeline === void 0) { pipeline = []; }
|
|
1821
1820
|
var stream = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).watch(pipeline, options);
|
|
@@ -1825,7 +1824,7 @@ var Collection = /** @class */ (function () {
|
|
|
1825
1824
|
});
|
|
1826
1825
|
return stream;
|
|
1827
1826
|
};
|
|
1828
|
-
|
|
1827
|
+
MongoManagerCollection.prototype.watchCollectionWithAggregate = function (pipeline, options) {
|
|
1829
1828
|
var _this = this;
|
|
1830
1829
|
if (pipeline === void 0) { pipeline = []; }
|
|
1831
1830
|
var stream = index_1.ResolveIOServer.getMainDB().collection(this.collectionName, this.collectionOptions).watch(pipeline, options);
|
|
@@ -1835,15 +1834,15 @@ var Collection = /** @class */ (function () {
|
|
|
1835
1834
|
});
|
|
1836
1835
|
return stream;
|
|
1837
1836
|
};
|
|
1838
|
-
return
|
|
1837
|
+
return MongoManagerCollection;
|
|
1839
1838
|
}());
|
|
1840
|
-
exports.
|
|
1841
|
-
var
|
|
1842
|
-
__extends(
|
|
1843
|
-
function
|
|
1839
|
+
exports.MongoManagerCollection = MongoManagerCollection;
|
|
1840
|
+
var MongoManagerUserCollection = /** @class */ (function (_super) {
|
|
1841
|
+
__extends(MongoManagerUserCollection, _super);
|
|
1842
|
+
function MongoManagerUserCollection() {
|
|
1844
1843
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1845
1844
|
}
|
|
1846
|
-
|
|
1845
|
+
MongoManagerUserCollection.prototype.authenticateStrategy = function () {
|
|
1847
1846
|
var _this = this;
|
|
1848
1847
|
return function (username, password, cb) { return __awaiter(_this, void 0, void 0, function () {
|
|
1849
1848
|
var user;
|
|
@@ -1867,7 +1866,7 @@ var UserCollection = /** @class */ (function (_super) {
|
|
|
1867
1866
|
});
|
|
1868
1867
|
}); };
|
|
1869
1868
|
};
|
|
1870
|
-
|
|
1869
|
+
MongoManagerUserCollection.prototype.authenticate = function (user, password) {
|
|
1871
1870
|
var _this = this;
|
|
1872
1871
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1873
1872
|
var attemptsInterval, calculatedInterval;
|
|
@@ -1957,12 +1956,12 @@ var UserCollection = /** @class */ (function (_super) {
|
|
|
1957
1956
|
});
|
|
1958
1957
|
}); });
|
|
1959
1958
|
};
|
|
1960
|
-
|
|
1959
|
+
MongoManagerUserCollection.prototype.serializeUser = function () {
|
|
1961
1960
|
return function (user, cb) {
|
|
1962
1961
|
cb(null, user.username);
|
|
1963
1962
|
};
|
|
1964
1963
|
};
|
|
1965
|
-
|
|
1964
|
+
MongoManagerUserCollection.prototype.deserializeUser = function () {
|
|
1966
1965
|
return function (username, cb) {
|
|
1967
1966
|
user_collection_1.Users.findOne({ username: username }).then(function (res) {
|
|
1968
1967
|
cb(null, res);
|
|
@@ -1971,7 +1970,7 @@ var UserCollection = /** @class */ (function (_super) {
|
|
|
1971
1970
|
});
|
|
1972
1971
|
};
|
|
1973
1972
|
};
|
|
1974
|
-
|
|
1973
|
+
MongoManagerUserCollection.prototype.setPassword = function (user, password) {
|
|
1975
1974
|
var _this = this;
|
|
1976
1975
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1977
1976
|
var saltBuffer, salt, hashRaw, hash;
|
|
@@ -2005,7 +2004,7 @@ var UserCollection = /** @class */ (function (_super) {
|
|
|
2005
2004
|
}); });
|
|
2006
2005
|
};
|
|
2007
2006
|
;
|
|
2008
|
-
|
|
2007
|
+
MongoManagerUserCollection.prototype.changePassword = function (user, oldPassword, newPassword) {
|
|
2009
2008
|
var _this = this;
|
|
2010
2009
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
2011
2010
|
var authUser;
|
|
@@ -2034,7 +2033,7 @@ var UserCollection = /** @class */ (function (_super) {
|
|
|
2034
2033
|
});
|
|
2035
2034
|
}); });
|
|
2036
2035
|
};
|
|
2037
|
-
|
|
2036
|
+
MongoManagerUserCollection.prototype.register = function (user, password) {
|
|
2038
2037
|
var _this = this;
|
|
2039
2038
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
2040
2039
|
var dbUser;
|
|
@@ -2066,12 +2065,12 @@ var UserCollection = /** @class */ (function (_super) {
|
|
|
2066
2065
|
});
|
|
2067
2066
|
}); });
|
|
2068
2067
|
};
|
|
2069
|
-
|
|
2068
|
+
MongoManagerUserCollection.prototype.resetAttempts = function (user) {
|
|
2070
2069
|
return user_collection_1.Users.updateOne({ _id: user._id }, { $set: { attempts: 0 } });
|
|
2071
2070
|
};
|
|
2072
|
-
return
|
|
2073
|
-
}(
|
|
2074
|
-
exports.
|
|
2071
|
+
return MongoManagerUserCollection;
|
|
2072
|
+
}(MongoManagerCollection));
|
|
2073
|
+
exports.MongoManagerUserCollection = MongoManagerUserCollection;
|
|
2075
2074
|
function objectIdHexString() {
|
|
2076
2075
|
var objectId = new mongodb_1.ObjectId();
|
|
2077
2076
|
return objectId.toHexString();
|