We will start by modeling the query, either using MongoDB Compass or directly from the mongo shell. In order to run this query, we need information from the bookings collection's bookingInfo field (described in Chapter 7, Advanced MongoDB Database Design). You can see that there is often a twist. In this case, the twist is that we must be sure to only include bookings where the payment status is confirmed.
Query criteria are grouped together using the $and query operator. We use a regular expression to match the target year of 2018. In addition, we add a condition that specifies that only documents where the payment status is confirmed are matched. It is also worth mentioning at this point that in order to reference a property of an embedded object, you should use a dot (.) as a separator. Thus, in order to match arrivalDate, which is a property of the object represented by the bookingInfo field, we use this syntax:
bookingInfo.arrivalDate...