Skip to content

Commit 3be7f59

Browse files
committed
Snnitize the newly supported pipeline
1 parent 2d33f24 commit 3be7f59

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/server/data_form.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,26 @@ export class FormsAngular {
14731473
// to ensure that the pipeline returns fields used by the findFunc
14741474
console.log(`In some scenarios $lookups that use pipelines may not provide all the fields used by the 'findFunc' of a collection.
14751475
If you get no results returned this might be the explanation.`)
1476+
1477+
/* Sanitise the pipeline we are doing a lookup with, removing hidden fields from that collection */
1478+
const lookupCollectionName = stage.$lookup.from;
1479+
const lookupResource =
1480+
that.getResourceFromCollection(lookupCollectionName);
1481+
let lookupHiddenLookupFields = {};
1482+
if (lookupResource) {
1483+
if (lookupResource.options?.hide?.length > 0) {
1484+
lookupHiddenLookupFields = this.generateHiddenFields(
1485+
lookupResource,
1486+
false
1487+
);
1488+
}
1489+
}
1490+
stage.$lookup.pipeline = await that.sanitisePipeline(
1491+
stage.$lookup.pipeline,
1492+
lookupHiddenLookupFields,
1493+
findFuncQry,
1494+
req
1495+
);
14761496
} else {
14771497
throw new Error(
14781498
`No support for $lookup of with properties ${lookupProps.join(', ')}`

0 commit comments

Comments
 (0)