MongoDB querying and CRUD operations
Let’s see MongoDB in action and experience firsthand the power of the most popular NoSQL database. This section will show you the most essential MongoDB commands, through simple examples. These methods will enable you, as a developer, to take control of your data, create new documents, query documents by using different criteria and conditions, perform simple and more complex aggregations, and output data in various forms.
Although you will be talking to MongoDB through the Python drivers (Motor and PyMongo), it is helpful to learn how to write queries directly at first. You’ll begin by querying the sample_mflix.movies
dataset that was imported into your cluster at the time of cluster creation, then you’ll go through the process of creating new data—inserting, updating, and so on.
Let’s first define the two options for executing MongoDB commands, as follows:
- Compass GUI
- MongoDB Shell (
mongosh
...