c2-mongoose 2.1.467 → 2.1.469

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.
@@ -3,6 +3,7 @@ export interface IForeingData {
3
3
  parentFieldOnChild: string;
4
4
  match?: any;
5
5
  sort?: any;
6
+ pipeline?: any[];
6
7
  }
7
8
  declare class OneToManyV3FlowItem {
8
9
  execute(foreings: IForeingData[], populate?: string): any[];
@@ -34,27 +34,18 @@ var OneToManyV3FlowItem = /** @class */ (function () {
34
34
  $sort: foreing.sort
35
35
  });
36
36
  }
37
- // if (foreing.match) {
37
+ if (foreing.pipeline) {
38
+ pipeline = __spreadArray(__spreadArray([], pipeline, true), foreing.pipeline, true);
39
+ }
38
40
  populateClauseLookup.push({
39
41
  $lookup: {
40
42
  from: foreing.collectionChild,
41
- // let: { localField: '$_id' },
42
43
  localField: "_id",
43
44
  foreignField: foreing.parentFieldOnChild,
44
45
  as: labeled,
45
46
  pipeline: __spreadArray([], pipeline, true)
46
47
  }
47
48
  });
48
- // } else {
49
- // populateClauseLookup.push({
50
- // $lookup: {
51
- // from: foreing.collectionChild, // The collection where user data is stored
52
- // localField: "_id",
53
- // foreignField: foreing.parentFieldOnChild,
54
- // as: labeled
55
- // }
56
- // })
57
- // }
58
49
  collection = __spreadArray(__spreadArray([], collection, true), populateClauseLookup, true);
59
50
  var model = global.connectionMongoose.models[Object.keys(global.connectionMongoose.models).find(function (key) { return global.connectionMongoose.models[key].collection.name === foreing.collectionChild; })];
60
51
  if (model) {
@@ -62,7 +53,6 @@ var OneToManyV3FlowItem = /** @class */ (function () {
62
53
  for (var _i = 0, populates_1 = populates; _i < populates_1.length; _i++) {
63
54
  var populate_1 = populates_1[_i];
64
55
  var _a = populate_1.split('.'), first = _a[0], rest = _a.slice(1);
65
- // collection = [...collection, ...PopulateFlowItem.execute(populates, model)]
66
56
  collection = __spreadArray(__spreadArray([], collection, true), LookupArrayFlowItem_1.default.execute(first, rest, collection, model, false), true);
67
57
  }
68
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.467",
3
+ "version": "2.1.469",
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",
@@ -5,6 +5,7 @@ export interface IForeingData {
5
5
  parentFieldOnChild: string;
6
6
  match?: any
7
7
  sort?: any
8
+ pipeline?: any[]
8
9
  }
9
10
 
10
11
  class OneToManyV3FlowItem {
@@ -15,7 +16,7 @@ class OneToManyV3FlowItem {
15
16
  const labeled = camelCase(foreing.collectionChild)
16
17
  const populateClauseLookup: any[] = []
17
18
 
18
- const pipeline: any[] = []
19
+ let pipeline: any[] = []
19
20
 
20
21
  if (foreing.match) {
21
22
  pipeline.push({
@@ -29,27 +30,19 @@ class OneToManyV3FlowItem {
29
30
  })
30
31
  }
31
32
 
32
- // if (foreing.match) {
33
- populateClauseLookup.push({
34
- $lookup: {
35
- from: foreing.collectionChild, // The collection where user data is stored
36
- // let: { localField: '$_id' },
37
- localField: "_id",
38
- foreignField: foreing.parentFieldOnChild,
39
- as: labeled,
40
- pipeline: [ ...pipeline ]
41
- }
42
- })
43
- // } else {
44
- // populateClauseLookup.push({
45
- // $lookup: {
46
- // from: foreing.collectionChild, // The collection where user data is stored
47
- // localField: "_id",
48
- // foreignField: foreing.parentFieldOnChild,
49
- // as: labeled
50
- // }
51
- // })
52
- // }
33
+ if (foreing.pipeline) {
34
+ pipeline = [...pipeline, ...foreing.pipeline]
35
+ }
36
+
37
+ populateClauseLookup.push({
38
+ $lookup: {
39
+ from: foreing.collectionChild, // The collection where user data is stored
40
+ localField: "_id",
41
+ foreignField: foreing.parentFieldOnChild,
42
+ as: labeled,
43
+ pipeline: [...pipeline]
44
+ }
45
+ })
53
46
 
54
47
  collection = [...collection, ...populateClauseLookup]
55
48
 
@@ -64,7 +57,6 @@ class OneToManyV3FlowItem {
64
57
 
65
58
  for (const populate of populates) {
66
59
  let [first, ...rest] = populate.split('.')
67
- // collection = [...collection, ...PopulateFlowItem.execute(populates, model)]
68
60
  collection = [...collection, ...LookupArrayFlowItem.execute(first, rest, collection, model, false)]
69
61
  }
70
62
  }