100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

MongoDB Cheat Sheet

MongoDB Cheat Sheet

MongoDB CRUD operations, aggregation pipeline, and indexing strategies.

2 PagesBeginnerApr 24, 2026

CRUD Operations

Create, read, update, delete documents.

javascript
db.users.insertOne({ name: "Alice", age: 30 });db.users.find({ age: { $gt: 18 } });db.users.updateOne({ name: "Alice" }, { $set: { age: 31 } });db.users.deleteOne({ name: "Alice" });

Query Operators

Common comparison and logical operators.

javascript
db.users.find({ age: { $gte: 18, $lte: 65 } });db.users.find({ $or: [{ role: "admin" }, { role: "editor" }] });db.users.find({ tags: { $in: ["vip", "beta"] } });

Aggregation Pipeline

Transform and summarize documents.

javascript
db.orders.aggregate([  { $match: { status: "paid" } },  { $group: { _id: "$customerId", total: { $sum: "$amount" } } },  { $sort: { total: -1 } },]);

Indexing

Speed up queries with indexes.

javascript
db.users.createIndex({ email: 1 }, { unique: true });db.users.getIndexes();
Pro Tip

Index the fields you query and sort on most often — use .explain("executionStats") to verify a query is actually using one.

Was this cheat sheet helpful?

Explore Topics

#MongoDB#MongoDBCheatSheet#Database#Beginner#CRUDOperations#QueryOperators#AggregationPipeline#Indexing#Databases#DevOps#CheatSheet#SkillVeris