@dnax/core 0.62.1 → 0.63.0

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.
@@ -15,6 +15,10 @@ export type findParam = {
15
15
  $include?: Array<string | Lookup>;
16
16
  $project?: object;
17
17
  $matchInclude?: object;
18
+ $group?: {
19
+ _id: any;
20
+ [key: string]: any;
21
+ };
18
22
  $sample?: {
19
23
  size: number;
20
24
  };
@@ -1446,7 +1446,7 @@ class useRest {
1446
1446
  state: sessionStorage()?.get()?.state,
1447
1447
  uuid: sessionStorage()?.get()?.uuid,
1448
1448
  });
1449
- return resolve(result.doc);
1449
+ return resolve(toJson(result?.doc || {}));
1450
1450
  } catch (err) {
1451
1451
  return reject(err);
1452
1452
  }
@@ -54,7 +54,6 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
54
54
  if (params?.$include?.length) {
55
55
  params.$include.map((inc) => {
56
56
  // AutoInclue by string
57
-
58
57
  if (typeof inc === "string" && col) {
59
58
  let field = getFieldCollection(inc, col);
60
59
  if (field) {
@@ -66,7 +65,7 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
66
65
  as: inc,
67
66
  },
68
67
  });
69
- if (!field.relation?.hasMany) {
68
+ if (!field?.relation?.hasMany) {
70
69
  pipeline.push({
71
70
  $unwind: {
72
71
  path: `$${inc}`,
@@ -109,6 +108,15 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
109
108
  preserveNullAndEmptyArrays: true,
110
109
  },
111
110
  });
111
+ } else {
112
+ if (!field?.relation?.hasMany) {
113
+ pipeline.push({
114
+ $unwind: {
115
+ path: `$${inc}`,
116
+ preserveNullAndEmptyArrays: true,
117
+ },
118
+ });
119
+ }
112
120
  }
113
121
  }
114
122
  });
@@ -134,6 +142,13 @@ function buildPipeline(params: findParam, col?: Collection | undefined | null) {
134
142
  $sample: params.$sample,
135
143
  });
136
144
  }
145
+
146
+ if (params?.$group?._id) {
147
+ pipeline.push({
148
+ $group: params?.$group,
149
+ });
150
+ }
151
+
137
152
  return pipeline || [];
138
153
  }
139
154
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.62.1",
3
+ "version": "0.63.0",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {