Is there a reason the match fields are called localField and foreignField under $lookup but connectFromField and connectToField under $graphLookup?
$graphLookup does not use
localField as the field is not local.
I guess it’s also confusing that localField and fromField refer to different collections (unless doing a self lookup). But in
$graphLookup both are form the from collection, unless doing a self lookup.
So the connect fields are the way the algorithm “walks” the from collection.
OK, I see why “localField” and “foreignField” don’t make sense in the $graphLookup contexts. But it would have been helpful if the names “connectFromField” and “connectToField” had been used for $lookup as well as for $graphLookup, setting aside the traditional idea of a “foreign” key. Still, understanding this will help me keep the nomenclature straight in my head! Thanks.
That’s true, and I guess this obeys the order of creation of the stages, but I can’t say more than that.