@dnax/core 0.62.2 → 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.
- package/driver/mongo/@types.ts +4 -0
- package/driver/mongo/utils.ts +17 -2
- package/package.json +1 -1
package/driver/mongo/@types.ts
CHANGED
package/driver/mongo/utils.ts
CHANGED
|
@@ -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
|
|
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
|
|