3 Communicating with MongoDB

 

This chapter covers

  • Getting an overview of the MongoDB Wire Protocol
  • Customizing MongoDB Shell
  • Introducing MongoDB Compass GUI
  • Connecting to the MongoDB database using the Node.js driver
  • Communicating with MongoDB using the Python driver
  • Querying MongoDB with Ruby drivers

In this chapter, I delve into the fundamentals of interacting with MongoDB through the MongoDB Wire Protocol. I show you how to customize the MongoDB Shell (mongosh) for your development needs and introduce MongoDB Compass, a user-friendly graphical user interface (GUI). Finally, I demonstrate how to connect your applications to MongoDB using Node.js, Python, and Ruby drivers (widely used with MongoDB). By understanding these connectivity methods, you’ll be better equipped to build reliable, efficient applications that communicate seamlessly with your database regardless of the tech stack.

3.1 Interacting via MongoDB Wire Protocol

3.2 Discovering mongosh

3.2.1 Connecting to MongoDB Atlas

3.2.2 Connecting to self-hosted deployments

3.2.3 Performing operations

3.2.4 Viewing mongosh logs

3.2.5 Running scripts in mongosh

3.2.6 Configuring mongosh

3.2.7 Using .mongoshrc.js

3.3 Playing with MongoDB Compass

3.4 Connecting using MongoDB drivers

3.5 Using the Node.js driver

3.6 Employing Python drivers

3.6.1 PyMongo

3.6.2 Motor

3.6.3 PyMongo vs. Motor

3.7 Integrating Ruby drivers

3.8 Learning Mongoid

Summary