Hi folks!
I’m having a great time going through M001 and am hoping someone can do a little extra explaining to help me get why things work the way they do in the “Query Operators - Logic” lecture (in Chapter 4).
Our instructor, Yuliya, is explaining the distinction between implicit vs. explicit $and
, and the situations where explicit $and
is crucial. As an example, we head to the routes
collection to try and find out how many CR2
and A81
airplanes come through the KZN
airport.
It’s stated in the lecture that when we run the following query (without the explicit $and
)…
{"$or": [{dst_airport: "KZN"}, {src_airport: "KZN"}] },
{"$or": [{airplane: "CR2"}, {airplane: "A81"}] }
the above may get us results with the right airport but the wrong airplane.
Why does this happen? (And why, by contrast, does usage of explicit $and
ensure we get only the right airplanes in our results?) Any color you can add is much appreciated.
Thanks,
Ana