The homework problem with the air_alliances and air_routes really threw me for a loop. And I’m now realizing why:
In the homework solution, I can’t wrap my head around why the lookup works. Specifically, the lookup is seemingly working by equality matching localField to an ELEMENT OF the foreignField.
First, I would just like to confirm that this is indeed the case. Because reading the $lookup documentation, I can see no indication that this is how it SHOULD work.
Of course, it could come down to the fact that I’m not completely clear on how MongoDB does its equality matching - but I’m surprised that it worked as it did, since air_route.airline is within the air_alliances.airlines array - NOT equal to any instance of it.