DeepFrontend
Practice ArenaBlogSign in
Go Pro
DeepFrontend

Interview-grade learning paths and hands-on practice for mid-to-senior engineers. Master internals, patterns, and system architecture with runnable code.

All systems operational

Core Courses

  • -JavaScript Internals
  • -React Reconciliation
  • -TypeScript rigor
  • -Next.js Caching
  • -Node.js Event Loop
  • -System Design
  • -Web Security
  • -CSS & Page Layouts

Explore

  • Learning Paths
  • Practice Arena
  • Pricing Options
  • HTML Sitemap

Resources

  • Privacy Policy
  • Terms of Service
  • Email Support

© 2026 DeepFrontend. All rights reserved.

Expert learning environments for web engineering teams.

Home/Databases/CRUD & Collections
beginner20 min read·Updated Jul 2026Expert reviewed

CRUD & Collections

MongoDB is a document-oriented NoSQL database. By storing data in flexible, JSON-like BSON documents grouped in collections, developers build applications rapidly without schema migration overhead.

mongodbnosqlcruddocumentscollectionsbson

Knowledge Check

2 questions · pass at 70%

0/2
mediummcq

1. What happens in MongoDB if you perform an update without using an update operator like `$set`?


Interview Questions

1 questions

Cheatsheet

Download-ready reference
Cheatsheet
Document   BSON record (JSON-like, up to 16MB).
Collection Group of documents. Equivalent to a SQL Table.

CRUD Commands:
  Insert:  db.col.insertOne({ ... })
  Find:    db.col.find({ field: value })
  Update:  db.col.updateOne({ filter }, { $set: { field: newValue } })
  Delete:  db.col.deleteOne({ filter })

Operators:
  $set     Modify/insert fields.
  $push    Append to arrays.
  $inc     Increment numeric value.
  $unset   Delete field.

Related topics

Mongoose (Schema Design, Validation)Pro

On this page

20m
Knowledge CheckInterview QuestionsCheatsheet

Concept#

Document-Oriented NoSQL#

In relational databases, data is split into structured rows and tables, requiring foreign keys to join relationships.

MongoDB stores data as documents (BSON format, a binary representation of JSON) grouped inside collections. Documents can have varying structures, nested objects, and arrays:

{
  "_id": "60c72b2f9b1d8b2bad000001",
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "skills": ["math", "programming"],
  "profile": {
    "title": "First Programmer",
    "verified": true
  }
}

Basic CRUD Operations#

  • Create: Insert documents into a collection.
    db.users.insertOne({ name: "Grace Hopper", email: "grace@example.com" });
  • Read: Query documents using query filters.
    db.users.find({ "profile.verified": true });
  • Update: Modify existing documents using update operators like $set, , or .

Common Mistakes#

1. Forgetting to use update operators like $set#

If you run db.users.updateOne({ id: 1 }, { status: "active" }), MongoDB replaces the entire document with { status: "active" } instead of only updating the status field. Always wrap modifications in $set or other operators:

db.users.updateOne({ id: 1 }, { $set: { status: "active" } });

2. Treating MongoDB like a relational database#

Creating excessive joins (via $lookup) in MongoDB is slow because NoSQL databases are optimized for denormalized, nested data structures. Embed documents unless data relations change frequently.


Best Practices#

  • De-normalize by default: Nest data (like user addresses) inside the parent document if the data is read together and does not grow infinitely.
  • Always limit queries: Never run db.collection.find() on large production tables without .limit(n) offsets.
  • Use index projection: Select only the fields you need using .find({}, { name: 1, email: 1 }) to reduce memory and transfer bandwidth.

$push
$inc
db.users.updateOne({ name: "Ada Lovelace" }, { $set: { "profile.verified": true } });
  • Delete: Remove documents.
    db.users.deleteOne({ email: "ada@example.com" });