Result not as expected when used depthField in $graphLookup


I am trying to execute the following command and do not get the results as expected as this is the same command as used in the class chapter 3 $graphLookup: maxDepth and depthField

$match: {name: “Dev”},

                    {$graphLookup: {
                     from: "child_reference",
                     startWith: "$direct_reports",
                     connectFromField: "direct_reports",
                     connectToField: "name",
                     as: "descendants",
                     maxDepth: 1,
                     depthField: "level"}

I am not able to identify the issue

Any help?



pretty() is a function, and must have the () after the command. As it is, what you’re seeing is the code for the function, you’re not executing it. Good luck.

You got it. Yes it’s a function and not sure how I missed those brackets. Thank you for finding that out. It works great now.