summaryrefslogtreecommitdiff
path: root/jstests/aggregation/sources/graphLookup/filter.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/aggregation/sources/graphLookup/filter.js')
-rw-r--r--jstests/aggregation/sources/graphLookup/filter.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/aggregation/sources/graphLookup/filter.js b/jstests/aggregation/sources/graphLookup/filter.js
index 4b46c843d9a..da828cb66c7 100644
--- a/jstests/aggregation/sources/graphLookup/filter.js
+++ b/jstests/aggregation/sources/graphLookup/filter.js
@@ -91,4 +91,28 @@ res = local
.toArray()[0];
assert.eq(res.results.length, 1);
+
+// $expr within `restrictSearchWithMatch` has access to variables declared at a higher level.
+res = local
+ .aggregate([{
+ $lookup: {
+ from: "local",
+ let : {foo: true},
+ pipeline: [{
+ $graphLookup: {
+ from: "foreign",
+ startWith: "$starting",
+ connectFromField: "to",
+ connectToField: "from",
+ as: "results",
+ restrictSearchWithMatch:
+ {$expr: {$eq: ["$shouldBeIncluded", "$$foo"]}}
+ }
+ }],
+ as: "array"
+ }
+ }])
+ .toArray()[0];
+
+assert.eq(res.array[0].results.length, 1);
})();