MongoDB $graphLookup
Follow a relationship recursively through one collection.
Start with one value, match it against `connectToField`, then reuse `connectFromField` from every match to continue traversing. Set a maximum depth when the domain has a known bound.
Stages are the top-level steps in a pipeline. Each stage receives documents, changes the stream in one specific way, and passes its output to the next stage.
Course use: Beyond Hard Mode.
Example pipeline syntax
{ $graphLookup: {
from: "categories",
startWith: "$parentId",
connectFromField: "parentId",
connectToField: "_id",
as: "ancestors"
} }