Management has come to you with a request for a sales report for 2018, by country, broken down by month. You decide on a simple strategy: perform a query on the purchases collection that returns the total extended price of each purchase, along with the purchase date and country. Before getting into the actual code, we will look at the core pymongo collection command; that is, find().
Please note that you could use the MongoDB Aggregation Framework to provide the requested breakdown. Aggregation is a complex topic, however, and is covered in Chapter 9, Handling Complex Queries in MongoDB.