MongoDB Developer
MongoDB
MongoDB Developer Centerchevron-right
Developer Topicschevron-right
Productschevron-right
MongoDBchevron-right

MongoDB Cheat Sheet

Maxime BeugnetPublished Jan 31, 2022 • Updated May 13, 2022
MongoDB
Copy Link
facebook icontwitter iconlinkedin icon
random alt
Rate this quickstart
star-empty
star-empty
star-empty
star-empty
star-empty
First steps in the MongoDB World? This cheat sheet is filled with some handy tips, commands, and quick references to get you connected and CRUD'ing in no time!
  • Get a free MongoDB cluster in MongoDB Atlas.
  • Follow a course in MongoDB University.

Table of Contents

Connect MongoDB Shell

  • To connect with the new mongosh, just replace mongo by mongosh.

Helpers

Show Databases
Switch Database
Show Collections
Run JavaScript File

CRUD

Create
Read
Update
Delete

Databases and Collections

Drop
Create Collection
Other Collection Functions

Indexes

List Indexes
Create Indexes
Drop Indexes
Hide/Unhide Indexes

Handy commands

Change Streams

Replica Set

Sharded Cluster

Wrap-up

I hope you liked my little but - hopefully - helpful cheat sheet. Of course, this list isn't exhaustive at all. There are a lot more commands but I'm sure you will find them in the MongoDB documentation.
If you feel like I forgot a critical command in this list, please send me a tweet and I will make sure to fix it.
Check out our free courses on MongoDB University if you are not too sure what some of the above commands are doing.
If you have questions, please head to our developer community website where the MongoDB engineers and the MongoDB community will help you build your next big idea with MongoDB.

Copy Link
facebook icontwitter iconlinkedin icon
Rate this quickstart
star-empty
star-empty
star-empty
star-empty
star-empty
Related
Tutorial

Joining Collections in MongoDB with .NET Core and an Aggregation Pipeline


May 16, 2022
Article

Set Global Read and Write Concerns in MongoDB 4.4


Sep 23, 2022
Podcast

Making Diabetes Data More Accessible and Meaningful with Tidepool and MongoDB


May 16, 2022
Podcast

Schema Suggestions with Julia Oppenheim - Podcast Episode 59


May 20, 2022
Table of Contents