What are the 4 basic operations in MongoDB?

MongoDB, being a NoSQL database, revolves around collections and documents instead of tables and rows. Its four basic operations, also known as CRUD operations, are:

1. Create

This operation is used to add new documents to a collection. It corresponds to inserting data.

  • Command: insertOne() or insertMany()
  • Example:
    db.users.insertOne({ name: "Alice", age: 30 }); db.users.insertMany([{ name: "Bob", age: 25 }, { name: "Charlie", age: 35 }]);

2. Read

This operation retrieves documents from a collection. You can use queries to filter and find specific data.

  • Command: find() or findOne()
  • Example:
    db.users.find({ age: { $gt: 25 } }); // Find users older than 25 db.users.findOne({ name: "Alice" }); // Find the first user named Alice

3. Update

This operation modifies existing documents in a collection. You can update one or multiple documents.

  • Command: updateOne(), updateMany(), or replaceOne()
  • Example:
    db.users.updateOne({ name: "Alice" }, { $set: { age: 31 } }); // Update Alice's age to 31 db.users.updateMany({}, { $inc: { age: 1 } }); // Increment age of all users by 1

4. Delete

This operation removes documents from a collection. You can delete one or multiple documents.

  • Command: deleteOne() or deleteMany()
  • Example:
    db.users.deleteOne({ name: "Alice" }); // Delete the first document named Alice db.users.deleteMany({ age: { $lt: 30 } }); // Delete all users younger than 30

Learn MongoDB Efficiently

If you're preparing for interviews or want a deep dive into MongoDB and database concepts, consider these resources:

Understanding these operations is essential for mastering MongoDB's capabilities in application development and data management.

TAGS
Coding Interview
System Design Interview
CONTRIBUTOR
Design Gurus Team
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
Mention the influences of cloud services.
How do you define SLIs/SLOs/SLAs and error budgets for a new service?
Define SLIs SLOs SLAs and error budgets with a clear step by step framework that balances reliability and speed with examples alerts burn rate rules and interview tips
Is a PayPal interview hard?
How to ace system design interview?
What is the most powerful sorting algorithm?
What is the package of Adobe for freshers?
Related Courses
Course image
Grokking the Coding Interview: Patterns for Coding Questions
Grokking the Coding Interview Patterns in Java, Python, JS, C++, C#, and Go. The most comprehensive course with 476 Lessons.
4.6
Discounted price for Your Region

$197

Course image
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
3.9
Discounted price for Your Region

$78

Course image
Grokking Data Structures & Algorithms for Coding Interviews
Unlock Coding Interview Success: Dive Deep into Data Structures and Algorithms.
4
Discounted price for Your Region

$78

Image
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.