What will the following query return? db.routes.find({ $and: [ { $or: [{ dst_airport: "IST" }, { src_airport: "IST" }] }, { $or: [{ stops: 0 }, { airline.name: "Turkish Airlines"}] }, ] })

Prepare for the MongoDB Associate Developer Exam with flashcards and practice multiple choice questions. Each question includes hints and explanations to ensure you're ready for test day.

The query presented is structured to find documents from the "routes" collection that satisfy a combination of conditions using the logical operators $and and $or.

The first part of the query uses $or to look for routes where either the destination airport (dst_airport) is "IST" or the source airport (src_airport) is also "IST". This means it will retrieve all flights that either land at or depart from Istanbul airport.

The second part of the query again employs $or, but focuses on flights that either have no stops (stops: 0) or are operated by "Turkish Airlines" (airline.name: "Turkish Airlines").

By combining these two conditions with $and, the query effectively captures all flights that either depart from or land at Istanbul airport and fulfills at least one of the criteria from the second part, which are either being nonstop flights or operated by Turkish Airlines.

Thus, the overall result of the query is that it will return all flights that are either departing from or landing at Istanbul airport and are either nonstop or operated by Turkish Airlines. This aligns perfectly with the interpretation provided in the answer, making it the correct choice.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy