@travetto/model-mongo 8.0.7 → 8.0.8
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/package.json +2 -2
- package/src/service.ts +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-mongo",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.8",
|
|
4
4
|
"description": "Mongo backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@travetto/config": "^8.0.3",
|
|
33
33
|
"@travetto/model": "^8.0.4",
|
|
34
34
|
"@travetto/model-indexed": "^8.0.4",
|
|
35
|
-
"@travetto/model-query": "^8.0.
|
|
35
|
+
"@travetto/model-query": "^8.0.8",
|
|
36
36
|
"mongodb": "^7.6.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
package/src/service.ts
CHANGED
|
@@ -730,8 +730,19 @@ export class MongoModelService
|
|
|
730
730
|
queryObject = { $and: [queryObject, MongoUtil.extractWhereFilter(cls, query.where)] };
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
const unwinds: object[] = [];
|
|
734
|
+
const segments = String(field).split('.');
|
|
735
|
+
for (let index = 1; index <= segments.length; index++) {
|
|
736
|
+
const subPath = segments.slice(0, index);
|
|
737
|
+
const fieldConfiguration = SchemaRegistryIndex.getNestedFieldConfig(cls, subPath);
|
|
738
|
+
if (fieldConfiguration?.array) {
|
|
739
|
+
unwinds.push({ $unwind: `$${subPath.join('.')}` });
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
733
743
|
const aggregations: object[] = [
|
|
734
744
|
{ $match: queryObject },
|
|
745
|
+
...unwinds,
|
|
735
746
|
{
|
|
736
747
|
$group: {
|
|
737
748
|
_id: `$${field}`,
|