@resolveio/server-lib 9.1.22 → 9.1.24

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.
@@ -39,7 +39,7 @@ export declare class Collection<T> {
39
39
  createLogs: boolean;
40
40
  useRB: boolean;
41
41
  constructor(collectionName: string, schema: object, useReportBuilder: any, reportBuilderLookupTables: LookupTables[], timestamps: any, createLogs: any, checkSchema: any);
42
- aggregate(pipeline: object[], options?: CollectionAggregationOptions): Promise<any[]>;
42
+ aggregate(pipeline: object[], options?: CollectionAggregationOptions, bypassLogs?: boolean): Promise<any[]>;
43
43
  aggregateCount(pipeline: object[], options?: CollectionAggregationOptions): Promise<number>;
44
44
  aggregateCursor(pipeline: object[], options?: CollectionAggregationOptions): import("mongodb").AggregationCursor<any>;
45
45
  aggregateStream(pipeline: object[], options?: CollectionAggregationOptions): import("mongodb").Cursor<any>;
@@ -221,21 +221,24 @@ var Collection = /** @class */ (function () {
221
221
  }
222
222
  }, 1);
223
223
  }
224
- Collection.prototype.aggregate = function (pipeline, options) {
224
+ Collection.prototype.aggregate = function (pipeline, options, bypassLogs) {
225
225
  var _this = this;
226
+ if (bypassLogs === void 0) { bypassLogs = false; }
226
227
  return new Promise(function (resolve, reject) {
227
- log_collection_1.Logs.insertOne({
228
- _id: objectIdHexString(),
229
- type: 'query',
230
- collection: _this.collectionName,
231
- id_document: '',
232
- payload: common_1.getBinarySize(JSON.stringify([pipeline, options])) < 200000 ? JSON.stringify([pipeline, options], null, 2) : 'Too Big',
233
- method: 'aggregate',
234
- id_user: '',
235
- user: '',
236
- messageId: 0,
237
- route: ''
238
- });
228
+ if (_this.createLogs && !bypassLogs) {
229
+ log_collection_1.Logs.insertOne({
230
+ _id: objectIdHexString(),
231
+ type: 'query',
232
+ collection: _this.collectionName,
233
+ id_document: '',
234
+ payload: common_1.getBinarySize(JSON.stringify([pipeline, options])) < 200000 ? JSON.stringify([pipeline, options], null, 2) : 'Too Big',
235
+ method: 'aggregate',
236
+ id_user: '',
237
+ user: '',
238
+ messageId: 0,
239
+ route: ''
240
+ });
241
+ }
239
242
  index_1.ResolveIOServer.getMongoManager().addToQueue({
240
243
  _id: 0,
241
244
  name_collection: _this.collectionName,
@@ -250,18 +253,20 @@ var Collection = /** @class */ (function () {
250
253
  else {
251
254
  resolve(res);
252
255
  }
253
- log_collection_1.Logs.insertOne({
254
- _id: objectIdHexString(),
255
- type: 'queryResponse',
256
- collection: _this.collectionName,
257
- id_document: '',
258
- payload: common_1.getBinarySize(JSON.stringify([err, res])) < 200000 ? JSON.stringify([err, res], null, 2) : 'Too Big',
259
- method: 'aggregate',
260
- id_user: '',
261
- user: '',
262
- messageId: 0,
263
- route: ''
264
- });
256
+ if (_this.createLogs && !bypassLogs) {
257
+ log_collection_1.Logs.insertOne({
258
+ _id: objectIdHexString(),
259
+ type: 'queryResponse',
260
+ collection: _this.collectionName,
261
+ id_document: '',
262
+ payload: common_1.getBinarySize(JSON.stringify([err, res])) < 200000 ? JSON.stringify([err, res], null, 2) : 'Too Big',
263
+ method: 'aggregate',
264
+ id_user: '',
265
+ user: '',
266
+ messageId: 0,
267
+ route: ''
268
+ });
269
+ }
265
270
  }],
266
271
  cbs_next: [],
267
272
  running: false
@@ -462,18 +467,20 @@ var Collection = /** @class */ (function () {
462
467
  else {
463
468
  resolve(res);
464
469
  }
465
- log_collection_1.Logs.insertOne({
466
- _id: objectIdHexString(),
467
- type: 'queryResponse',
468
- collection: _this.collectionName,
469
- id_document: '',
470
- payload: JSON.stringify([err, res], null, 2),
471
- method: 'find',
472
- id_user: '',
473
- user: '',
474
- messageId: 0,
475
- route: ''
476
- });
470
+ if (_this.createLogs && !bypassLogs) {
471
+ log_collection_1.Logs.insertOne({
472
+ _id: objectIdHexString(),
473
+ type: 'queryResponse',
474
+ collection: _this.collectionName,
475
+ id_document: '',
476
+ payload: JSON.stringify([err, res], null, 2),
477
+ method: 'find',
478
+ id_user: '',
479
+ user: '',
480
+ messageId: 0,
481
+ route: ''
482
+ });
483
+ }
477
484
  }],
478
485
  cbs_next: [],
479
486
  running: false
@@ -545,18 +552,20 @@ var Collection = /** @class */ (function () {
545
552
  else {
546
553
  resolve(res);
547
554
  }
548
- log_collection_1.Logs.insertOne({
549
- _id: objectIdHexString(),
550
- type: 'queryResponse',
551
- collection: _this.collectionName,
552
- id_document: '',
553
- payload: JSON.stringify([err, res], null, 2),
554
- method: 'findOne',
555
- id_user: '',
556
- user: '',
557
- messageId: 0,
558
- route: ''
559
- });
555
+ if (_this.createLogs && !bypassLogs) {
556
+ log_collection_1.Logs.insertOne({
557
+ _id: objectIdHexString(),
558
+ type: 'queryResponse',
559
+ collection: _this.collectionName,
560
+ id_document: '',
561
+ payload: JSON.stringify([err, res], null, 2),
562
+ method: 'findOne',
563
+ id_user: '',
564
+ user: '',
565
+ messageId: 0,
566
+ route: ''
567
+ });
568
+ }
560
569
  }],
561
570
  cbs_next: [],
562
571
  running: false
@@ -600,32 +609,36 @@ var Collection = /** @class */ (function () {
600
609
  else {
601
610
  reject(res.lastErrorObject);
602
611
  }
603
- log_collection_1.Logs.insertOne({
604
- _id: objectIdHexString(),
605
- type: 'queryResponse',
606
- collection: _this.collectionName,
607
- id_document: '',
608
- payload: JSON.stringify([res.value], null, 2),
609
- method: 'findOneAndDelete',
610
- id_user: '',
611
- user: '',
612
- messageId: 0,
613
- route: ''
614
- });
612
+ if (_this.createLogs && !bypassLogs) {
613
+ log_collection_1.Logs.insertOne({
614
+ _id: objectIdHexString(),
615
+ type: 'queryResponse',
616
+ collection: _this.collectionName,
617
+ id_document: '',
618
+ payload: JSON.stringify([res.value], null, 2),
619
+ method: 'findOneAndDelete',
620
+ id_user: '',
621
+ user: '',
622
+ messageId: 0,
623
+ route: ''
624
+ });
625
+ }
615
626
  }, function (err) {
616
627
  reject(err);
617
- log_collection_1.Logs.insertOne({
618
- _id: objectIdHexString(),
619
- type: 'queryResponse',
620
- collection: _this.collectionName,
621
- id_document: '',
622
- payload: JSON.stringify([err], null, 2),
623
- method: 'findOneAndDelete',
624
- id_user: '',
625
- user: '',
626
- messageId: 0,
627
- route: ''
628
- });
628
+ if (_this.createLogs && !bypassLogs) {
629
+ log_collection_1.Logs.insertOne({
630
+ _id: objectIdHexString(),
631
+ type: 'queryResponse',
632
+ collection: _this.collectionName,
633
+ id_document: '',
634
+ payload: JSON.stringify([err], null, 2),
635
+ method: 'findOneAndDelete',
636
+ id_user: '',
637
+ user: '',
638
+ messageId: 0,
639
+ route: ''
640
+ });
641
+ }
629
642
  });
630
643
  return [2 /*return*/];
631
644
  }
@@ -684,32 +697,36 @@ var Collection = /** @class */ (function () {
684
697
  else {
685
698
  reject(res.lastErrorObject);
686
699
  }
687
- log_collection_1.Logs.insertOne({
688
- _id: objectIdHexString(),
689
- type: 'queryResponse',
690
- collection: _this.collectionName,
691
- id_document: '',
692
- payload: JSON.stringify([res.value], null, 2),
693
- method: 'findOneAndReplace',
694
- id_user: '',
695
- user: '',
696
- messageId: 0,
697
- route: ''
698
- });
700
+ if (_this.createLogs && !bypassLogs) {
701
+ log_collection_1.Logs.insertOne({
702
+ _id: objectIdHexString(),
703
+ type: 'queryResponse',
704
+ collection: _this.collectionName,
705
+ id_document: '',
706
+ payload: JSON.stringify([res.value], null, 2),
707
+ method: 'findOneAndReplace',
708
+ id_user: '',
709
+ user: '',
710
+ messageId: 0,
711
+ route: ''
712
+ });
713
+ }
699
714
  }, function (err) {
700
715
  reject(err);
701
- log_collection_1.Logs.insertOne({
702
- _id: objectIdHexString(),
703
- type: 'queryResponse',
704
- collection: _this.collectionName,
705
- id_document: '',
706
- payload: JSON.stringify([err], null, 2),
707
- method: 'findOneAndReplace',
708
- id_user: '',
709
- user: '',
710
- messageId: 0,
711
- route: ''
712
- });
716
+ if (_this.createLogs && !bypassLogs) {
717
+ log_collection_1.Logs.insertOne({
718
+ _id: objectIdHexString(),
719
+ type: 'queryResponse',
720
+ collection: _this.collectionName,
721
+ id_document: '',
722
+ payload: JSON.stringify([err], null, 2),
723
+ method: 'findOneAndReplace',
724
+ id_user: '',
725
+ user: '',
726
+ messageId: 0,
727
+ route: ''
728
+ });
729
+ }
713
730
  });
714
731
  return [2 /*return*/];
715
732
  }
@@ -773,32 +790,36 @@ var Collection = /** @class */ (function () {
773
790
  else {
774
791
  reject(res.lastErrorObject);
775
792
  }
776
- log_collection_1.Logs.insertOne({
777
- _id: objectIdHexString(),
778
- type: 'queryResponse',
779
- collection: _this.collectionName,
780
- id_document: '',
781
- payload: JSON.stringify([res.value], null, 2),
782
- method: 'findOneAndUpdate',
783
- id_user: '',
784
- user: '',
785
- messageId: 0,
786
- route: ''
787
- });
793
+ if (_this.createLogs && !bypassLogs) {
794
+ log_collection_1.Logs.insertOne({
795
+ _id: objectIdHexString(),
796
+ type: 'queryResponse',
797
+ collection: _this.collectionName,
798
+ id_document: '',
799
+ payload: JSON.stringify([res.value], null, 2),
800
+ method: 'findOneAndUpdate',
801
+ id_user: '',
802
+ user: '',
803
+ messageId: 0,
804
+ route: ''
805
+ });
806
+ }
788
807
  }, function (err) {
789
808
  reject(err);
790
- log_collection_1.Logs.insertOne({
791
- _id: objectIdHexString(),
792
- type: 'queryResponse',
793
- collection: _this.collectionName,
794
- id_document: '',
795
- payload: JSON.stringify([err], null, 2),
796
- method: 'findOneAndUpdate',
797
- id_user: '',
798
- user: '',
799
- messageId: 0,
800
- route: ''
801
- });
809
+ if (_this.createLogs && !bypassLogs) {
810
+ log_collection_1.Logs.insertOne({
811
+ _id: objectIdHexString(),
812
+ type: 'queryResponse',
813
+ collection: _this.collectionName,
814
+ id_document: '',
815
+ payload: JSON.stringify([err], null, 2),
816
+ method: 'findOneAndUpdate',
817
+ id_user: '',
818
+ user: '',
819
+ messageId: 0,
820
+ route: ''
821
+ });
822
+ }
802
823
  });
803
824
  return [2 /*return*/];
804
825
  }