MongoDB CRUD Operations: Insert and Find Documents

Learn how to create, find, and query MongoDB documents in the mongo shell.

MongoDB CRUD: Insert and Find

Unit Overview

In this unit, you will be introduced to CRUD operations in MongoDB by inserting and finding documents. Inserting and finding documents will help you discover the ease and usability of MongoDB. You'll also build your own queries that use comparison and logical operators. Using operators will make your queries more precise and, in turn, make your application easier to develop. Finally, you'll learn how to query elements in an array. Arrays are a crucial data type that you will encounter frequently, so it's important that you have a solid understanding of how to work with them.

Prerequisites

Lessons in This Unit

  • Lesson 01: Inserting Documents in a MongoDB Collection
  • Lesson 02: Finding Documents in a MongoDB Collection
  • Lesson 03: Finding Documents by Using Comparison Operators
  • Lesson 04: Querying on Array Elements in MongoDB
  • Lesson 05: Finding Documents by Using Logical Operators
  • 01.
    Lesson 1: Inserting Documents in a MongoDB Collection
    • Learn
    • Practice
  • 02.
    Lesson 2: Finding Documents in a MongoDB Collection
    • Learn
    • Practice
  • 03.
    Lesson 3: Finding Documents by Using Comparison Operators
    • Learn
    • Practice
  • 04.
    Lesson 4: Querying on Array Elements in MongoDB
    • Learn
    • Practice
  • 05.
    Lesson 5: Finding Documents by Using Logical Operators
    • Learn
    • Practice
  • 06.
    Conclusion
    • Learn
Parker Faucher | University Curriculum Engineer

Parker Faucher | University Curriculum Engineer

Parker is a Curriculum Engineer on the Education team at MongoDB. Prior to joining MongoDB, he helped maintain a world-class developer boot camp that was offered in multiple universities. He is a self-taught developer who loves being able to give back to the community that has helped him so much. 

Emily Pope | Senior Curriculum Designer

Emily Pope | Senior Curriculum Designer

Emily is a Senior Curriculum Designer at MongoDB. Prior to MongoDB, Emily worked closely with professors at MIT and Columbia to design bootcamps in full stack development and data science at Emeritus. She also worked as an instructional designer on database and computer science learning experiences at Cengage. Emily loves learning about the everchanging tech space and is passionate about making these skills accessible to a global audience.

NS
October 23, 2023 7:03 PM


RH
October 22, 2023 8:44 AM

Good.

RN
October 20, 2023 4:40 AM


SA
October 18, 2023 8:15 PM


GM
October 18, 2023 5:03 AM


Hi there and welcome! In this unit, you’ll learn how to insert and find documents in MongoDB.

I’m Julie Gauthier. I’m a Curriculum Engineer at MongoDB, and I’ll be working with you through this unit.

Creating and reading data are fundamental operations of any database. MongoDB makes it easy to create queries to insert and find data quickly.

In this unit, we’ll first explain how to insert a document into a database by using the insertOne() and insertMany() methods.

Next, we’ll use the find() method to retrieve documents from a collection in the database.

Then, we’ll build queries with comparison and logical operators.

Finally, we’ll use $elemMatch to query array elements..

The most effective way to learn a new skill is to apply it in a real-world scenario. So, we’ve set up integrated development environments with lab activities for you to practice as you work through the unit.

Before beginning this unit, you should have a basic understanding of the document model and how to connect to MongoDB.

If you’re new to these topics, we recommend first checking out their respective units, and then returning to this one.

If you’re ready, let’s get started!