Overview
Today's focus: learning the fundamentals of MongoDB. Understood what NoSQL means, how MongoDB stores data, and performed basic CRUD operations using the MongoDB shell or Compass.
What I Learned Today
- What MongoDB is and why it's used • Difference between SQL and NoSQL • Understanding databases, collections, and documents • Insert, Find, Update, Delete operations • Basics of MongoDB Compass or CLI
Key Concepts
MongoDB
- NoSQL document database • Stores data as BSON/JSON objects • Flexible schema (fields can vary)
Database Structure
- Database → Collection → Documents • Document = JSON object • Collection = group of documents
Basic CRUD Operations
Insert
Insert one document:
db.users.insertOne({ name: "John", age: 25 })
Insert multiple documents:
db.users.insertMany([
{ name: "A", age: 20 },
{ name: "B", age: 30 }
])
Find
Find all documents:
db.users.find()
Find with filter:
db.users.find({ age: 25 })