c2-mongoose 2.1.367 → 2.1.368

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.
@@ -1,6 +1,6 @@
1
1
  import mongoose from "mongoose";
2
2
  declare class LookupArrayFlowItem {
3
- execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>): never[] | undefined;
3
+ execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>): any[];
4
4
  }
5
5
  declare const _default: LookupArrayFlowItem;
6
6
  export default _default;
@@ -71,10 +71,11 @@ var LookupArrayFlowItem = /** @class */ (function () {
71
71
  }
72
72
  }
73
73
  });
74
- populateClauses = __spreadArray(__spreadArray([], populateClauses, true), populateClauseLookup, true);
74
+ return __spreadArray([], populateClauseLookup, true);
75
75
  }
76
76
  catch (error) {
77
77
  console.error(error.message);
78
+ return [];
78
79
  }
79
80
  };
80
81
  return LookupArrayFlowItem;
@@ -29,7 +29,7 @@ var PopulateFlowItem = /** @class */ (function () {
29
29
  return;
30
30
  var typeFirst = fieldDefinition.instance;
31
31
  if (typeFirst === 'Array') {
32
- LookupArrayFlowItem_1.default.execute(first, rest, populateClauses, modelRoot);
32
+ populateClauses = __spreadArray(__spreadArray([], populateClauses, true), LookupArrayFlowItem_1.default.execute(first, rest, populateClauses, modelRoot), true);
33
33
  return;
34
34
  }
35
35
  while ((typeFirst === 'Array' || typeFirst === 'Embedded') && (rest === null || rest === void 0 ? void 0 : rest.length)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.367",
3
+ "version": "2.1.368",
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",
@@ -2,7 +2,7 @@ import mongoose from "mongoose";
2
2
  import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem";
3
3
 
4
4
  class LookupArrayFlowItem {
5
- execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>) {
5
+ execute(previousPath: string, remainingPath: string[], populateClauses: any[], model: mongoose.Model<any>): any[] {
6
6
 
7
7
  const populateClauseLookup = []
8
8
 
@@ -67,9 +67,10 @@ class LookupArrayFlowItem {
67
67
  }
68
68
  });
69
69
 
70
- populateClauses = [...populateClauses, ...populateClauseLookup]
70
+ return [...populateClauseLookup]
71
71
  } catch (error: any) {
72
72
  console.error(error.message)
73
+ return []
73
74
  }
74
75
  }
75
76
  }
@@ -1,11 +1,11 @@
1
1
  import mongoose from "mongoose";
2
- import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem"
2
+ import GetFieldDefinitionFlowItem from "./GetFieldDefinitionFlowItem";
3
3
  import LookupArrayFlowItem from "./LookupArrayFlowItem";
4
4
 
5
5
  class PopulateFlowItem {
6
6
  execute(populates: string = "", modelRoot: mongoose.Model<any>): any[] {
7
7
  const populatesFields = populates.split(',').map((field: string) => field.trim()).filter((field: string) => field.length > 0);
8
-
8
+
9
9
  let populateClauses: any[] = []
10
10
  populatesFields?.forEach((populateField: string) => {
11
11
  let [first, ...rest] = populateField.split('.')
@@ -18,14 +18,14 @@ class PopulateFlowItem {
18
18
  let typeFirst = fieldDefinition.instance
19
19
 
20
20
  if (typeFirst === 'Array') {
21
- LookupArrayFlowItem.execute(first, rest, populateClauses, modelRoot)
21
+ populateClauses = [...populateClauses, ...LookupArrayFlowItem.execute(first, rest, populateClauses, modelRoot)]
22
22
  return
23
23
  }
24
24
 
25
25
  while ((typeFirst === 'Array' || typeFirst === 'Embedded') && rest?.length) {
26
26
  first = [first, rest[0]].join(".")
27
27
  rest.splice(0, 1)
28
-
28
+
29
29
  fieldDefinition = GetFieldDefinitionFlowItem.execute(modelRoot, first);
30
30
 
31
31
  if (!fieldDefinition) return;