@stemy/backend 3.2.1 → 3.2.4

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.
@@ -568,7 +568,7 @@
568
568
  if (foreignField === void 0) { foreignField = "_id"; }
569
569
  if (shouldUnwind === void 0) { shouldUnwind = true; }
570
570
  as = as || localField.replace("Id", "");
571
- var pipelines = [
571
+ var stages = [
572
572
  {
573
573
  $lookup: {
574
574
  from: from,
@@ -576,17 +576,18 @@
576
576
  foreignField: foreignField,
577
577
  as: as
578
578
  }
579
- }
580
- ];
581
- if (shouldUnwind) {
582
- pipelines.push({
579
+ },
580
+ {
583
581
  $unwind: {
584
582
  path: "$" + as,
585
583
  preserveNullAndEmptyArrays: true
586
584
  }
587
- });
585
+ }
586
+ ];
587
+ if (!shouldUnwind) {
588
+ stages.splice(1, 1);
588
589
  }
589
- return pipelines;
590
+ return stages;
590
591
  }
591
592
  function letsLookupStage(from, pipeline, as, letFields) {
592
593
  if (as === void 0) { as = null; }
@@ -602,6 +603,31 @@
602
603
  }
603
604
  };
604
605
  }
606
+ function matchStage(match) {
607
+ return { $match: match };
608
+ }
609
+ function matchField(field, filter, when) {
610
+ return { field: field, filter: filter, when: when };
611
+ }
612
+ function matchFieldStages() {
613
+ var fields = [];
614
+ for (var _i = 0; _i < arguments.length; _i++) {
615
+ fields[_i] = arguments[_i];
616
+ }
617
+ var match = {};
618
+ fields.forEach(function (field) {
619
+ if (field.when) {
620
+ match[field.field] = field.filter;
621
+ }
622
+ });
623
+ return Object.keys(match).length > 0 ? [matchStage(match)] : [];
624
+ }
625
+ function projectStage(fields) {
626
+ return { $project: fields };
627
+ }
628
+ function unwindStage(fieldOrOpts) {
629
+ return { $unwind: fieldOrOpts };
630
+ }
605
631
  function hydratePopulated(modelType, json) {
606
632
  var e_2, _a;
607
633
  var object = modelType.hydrate(json);
@@ -5032,14 +5058,14 @@
5032
5058
  __metadata$7("design:returntype", Promise)
5033
5059
  ], AssetsController.prototype, "getImage", null);
5034
5060
  __decorate$a([
5035
- routingControllers.Get("/by-name/:id"),
5061
+ routingControllers.Get("/by-name/:name"),
5036
5062
  __param$5(0, routingControllers.Param("name")), __param$5(1, routingControllers.Res()),
5037
5063
  __metadata$7("design:type", Function),
5038
5064
  __metadata$7("design:paramtypes", [String, Object]),
5039
5065
  __metadata$7("design:returntype", Promise)
5040
5066
  ], AssetsController.prototype, "getFileByName", null);
5041
5067
  __decorate$a([
5042
- routingControllers.Get("/by-name/image/:id"),
5068
+ routingControllers.Get("/by-name/image/:name"),
5043
5069
  __param$5(0, routingControllers.Param("name")), __param$5(1, routingControllers.QueryParams()), __param$5(2, routingControllers.Res()),
5044
5070
  __metadata$7("design:type", Function),
5045
5071
  __metadata$7("design:paramtypes", [String, Object, Object]),
@@ -6360,6 +6386,9 @@
6360
6386
  exports.lcFirst = lcFirst;
6361
6387
  exports.letsLookupStage = letsLookupStage;
6362
6388
  exports.lookupStages = lookupStages;
6389
+ exports.matchField = matchField;
6390
+ exports.matchFieldStages = matchFieldStages;
6391
+ exports.matchStage = matchStage;
6363
6392
  exports.md5 = md5;
6364
6393
  exports.mkdirRecursive = mkdirRecursive;
6365
6394
  exports.multiSubscription = multiSubscription;
@@ -6368,6 +6397,7 @@
6368
6397
  exports.padRight = padRight;
6369
6398
  exports.paginate = paginate;
6370
6399
  exports.paginateAggregations = paginateAggregations;
6400
+ exports.projectStage = projectStage;
6371
6401
  exports.promiseTimeout = promiseTimeout;
6372
6402
  exports.proxyFunction = proxyFunction;
6373
6403
  exports.proxyFunctions = proxyFunctions;
@@ -6383,6 +6413,7 @@
6383
6413
  exports.toImage = toImage;
6384
6414
  exports.ucFirst = ucFirst;
6385
6415
  exports.uniqueItems = uniqueItems;
6416
+ exports.unwindStage = unwindStage;
6386
6417
  exports.valueToPromise = valueToPromise;
6387
6418
  exports.writeFile = writeFile;
6388
6419