diff options
Diffstat (limited to 'jstests/aggregation/sources/graphLookup/variables.js')
-rw-r--r-- | jstests/aggregation/sources/graphLookup/variables.js | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/jstests/aggregation/sources/graphLookup/variables.js b/jstests/aggregation/sources/graphLookup/variables.js index 87e2c8b3975..63b1bbea244 100644 --- a/jstests/aggregation/sources/graphLookup/variables.js +++ b/jstests/aggregation/sources/graphLookup/variables.js @@ -2,17 +2,17 @@ * Tests to verify that $graphLookup can use the variables defined in an outer scope. */ (function() { - "use strict"; +"use strict"; - let local = db.graph_lookup_var_local; - let foreign = db.graph_lookup_var_foreign; - local.drop(); - foreign.drop(); +let local = db.graph_lookup_var_local; +let foreign = db.graph_lookup_var_foreign; +local.drop(); +foreign.drop(); - foreign.insert({from: "b", to: "a", _id: 0}); - local.insert({}); +foreign.insert({from: "b", to: "a", _id: 0}); +local.insert({}); - const basicGraphLookup = { +const basicGraphLookup = { $graphLookup: { from: "graph_lookup_var_foreign", startWith: "$$var1", @@ -22,7 +22,7 @@ } }; - const lookup = { +const lookup = { $lookup: { from: "graph_lookup_var_local", let : {var1: "a"}, @@ -31,11 +31,10 @@ } }; - // Verify that $graphLookup can use the variable 'var1' which is defined in parent $lookup. - let res = local.aggregate([lookup]).toArray(); - assert.eq(res.length, 1); - assert.eq(res[0].resultsFromLookup.length, 1); - assert.eq(res[0].resultsFromLookup[0].resultsFromGraphLookup.length, 1); - assert.eq(res[0].resultsFromLookup[0].resultsFromGraphLookup[0], {_id: 0, from: "b", to: "a"}); - +// Verify that $graphLookup can use the variable 'var1' which is defined in parent $lookup. +let res = local.aggregate([lookup]).toArray(); +assert.eq(res.length, 1); +assert.eq(res[0].resultsFromLookup.length, 1); +assert.eq(res[0].resultsFromLookup[0].resultsFromGraphLookup.length, 1); +assert.eq(res[0].resultsFromLookup[0].resultsFromGraphLookup[0], {_id: 0, from: "b", to: "a"}); })(); |