MongoDB Cheat Sheet

A Quick Reference with Essential tips and Commands

Say hello to MongoDB!

A distributed database system with a flexible JSON-like data model, designed for quick & easy query development & scalable, real-time data processing.

Why choose MongoDB?

1. Flexible JSON-like data model. 2. Distributed architecture with easy replication and scalability. 3. Rich set of analytical tools for data profiling and monitoring.

From beginner basics to advanced concepts, this cheat sheet has everything you need to master MongoDB. It is filled with handy tips & commands for quick reference.

Master MongiDB with this Cheat Sheet

1. To show all databases show dbs 2. Switch or create a database use acme 3. Drop a database db.dropDatabase()

Basic Commands

Finding Documents

1. Finds all documents. db.docx.find().prettyPrint() 2. Finds one random document db.docx.findOne() 3. Displays the names of document. db.docx.find({}, {name:true, _id:false})

Advanced Commands 

1. Count Rows db.docx.find().count() 2. Update one document db.docx.updateOne({"_id": 2}, {$set: {"title": 'revised title'}}) 3. Delete a Document db.docx.deleteOne({"_id" : 6})

Indexes

1. List Indexes db.docx.getIndexes() 2. Drop Index db.docx.dropIndex("name_3") 3. Hide Indexes db.docx.hideIndex("name_3")

Don’t miss these handy commands

1. Listing a Collection’s Records db.collectionname.find() 2. Search in MongoDb Database db.comments.find({lang:'Python'}) 3. Find a Single Record db.collectionname.findOne({"field2": "content"})

Dive into the world of MongoDB & improve your skills.

Get access to the full Cheat Sheet and start learning today!

Step Up Your Game with InterviewBit Web Stories

Don't miss out on the chance to upskill yourself with IntervewBit's engaging web stories.