reportingHierarchy
ここではオブジェクトの通常の配列なので、次の$match
を追加できます 集約へのステージ
db.employees.aggregate( [
{
$graphLookup: {
from: "employees",
startWith: "$reportsTo",
connectFromField: "reportsTo",
connectToField: "name",
as: "reportingHierarchy"
}
},
{
$match: {
$and: [{ "reportingHierarchy.name": "Andrew" }, {"reportingHierarchy.name": "Eliot" }]
}
}
] )