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
Core principles for building scalable, maintainable codebases
How do I practice coding for an interview?
Which company interview is easy?
How long is an Amazon job interview?
What is componentDidMount?
Can I learn system design without coding?
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

$72

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.