What is MongoDB and How Does it Work?
Advertisement
Ad
What is MongoDB?
MongoDB is the most popular NoSQL document database. Instead of tables and rows, it stores flexible JSON-like documents in collections — perfect for evolving data.
Documents vs Rows
// A MongoDB document
{
"_id": ObjectId("..."),
"name": "Sara",
"age": 25,
"hobbies": ["reading", "coding"],
"address": { "city": "Dubai" }
}
Basic Operations
db.users.insertOne({ name: "Sara", age: 25 });
db.users.find({ age: { $gt: 18 } });
db.users.updateOne({ name: "Sara" }, { $set: { age: 26 } });
db.users.deleteOne({ name: "Sara" });
Why MongoDB?
- Flexible schema — fields can vary per document.
- Scales horizontally (sharding).
- Native JSON works great with JavaScript/Node.
- Fast for large, unstructured data.
FAQs
MongoDB vs SQL?
MongoDB is schema-flexible NoSQL; SQL databases are structured. More in our MongoDB guides.
What is a collection?
The MongoDB equivalent of a table — a group of documents.
