c2-mongoose 2.1.453 → 2.1.455

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.
@@ -23,6 +23,17 @@ var OneToManyV3FlowItem = /** @class */ (function () {
23
23
  foreings === null || foreings === void 0 ? void 0 : foreings.forEach(function (foreing) {
24
24
  var labeled = (0, lodash_1.camelCase)(foreing.collectionChild);
25
25
  var populateClauseLookup = [];
26
+ var pipeline = [];
27
+ if (foreing.match) {
28
+ pipeline.push({
29
+ $match: foreing.match
30
+ });
31
+ }
32
+ if (foreing.sort) {
33
+ pipeline.push({
34
+ $sort: foreing.sort
35
+ });
36
+ }
26
37
  // if (foreing.match) {
27
38
  populateClauseLookup.push({
28
39
  $lookup: {
@@ -31,11 +42,7 @@ var OneToManyV3FlowItem = /** @class */ (function () {
31
42
  localField: "_id",
32
43
  foreignField: foreing.parentFieldOnChild,
33
44
  as: labeled,
34
- pipeline: [
35
- {
36
- $match: foreing.match
37
- },
38
- ]
45
+ pipeline: __spreadArray([], pipeline, true)
39
46
  }
40
47
  });
41
48
  // } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.453",
3
+ "version": "2.1.455",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,6 +15,20 @@ class OneToManyV3FlowItem {
15
15
  const labeled = camelCase(foreing.collectionChild)
16
16
  const populateClauseLookup: any[] = []
17
17
 
18
+ const pipeline: any[] = []
19
+
20
+ if (foreing.match) {
21
+ pipeline.push({
22
+ $match: foreing.match
23
+ })
24
+ }
25
+
26
+ if (foreing.sort) {
27
+ pipeline.push({
28
+ $sort: foreing.sort
29
+ })
30
+ }
31
+
18
32
  // if (foreing.match) {
19
33
  populateClauseLookup.push({
20
34
  $lookup: {
@@ -23,12 +37,7 @@ class OneToManyV3FlowItem {
23
37
  localField: "_id",
24
38
  foreignField: foreing.parentFieldOnChild,
25
39
  as: labeled,
26
- pipeline: [
27
- {
28
- $match:
29
- foreing.match
30
- },
31
- ]
40
+ pipeline: [ ...pipeline ]
32
41
  }
33
42
  })
34
43
  // } else {