MongoDB Developer
MongoDB
plus
Sign in to follow topics
MongoDB Developer Centerchevron-right
Developer Topicschevron-right
Productschevron-right
MongoDBchevron-right

MongoDB Cheat Sheet

Maxime Beugnet5 min read β€’ Published Jan 31, 2022 β€’ Updated Sep 27, 2023
MongoDB
Facebook Icontwitter iconlinkedin icon
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.

Updates

  • September 2023: Updated for MongoDB 7.0.

Table of Contents

Connect via

mongosh
πŸ” Table of Contents πŸ”

Helpers

Show Databases
Switch Database
Show Collections
Run JavaScript File
πŸ” Table of Contents πŸ”

CRUD

Create
Read
Update
Delete
πŸ” Table of Contents πŸ”

Databases and Collections

Drop
Create Collection
Other Collection Functions
πŸ” Table of Contents πŸ”

Indexes

List Indexes
Create Indexes
Drop Indexes
Hide/Unhide Indexes
πŸ” Table of Contents πŸ”

Handy commands

πŸ” Table of Contents πŸ”

Change Streams

πŸ” Table of Contents πŸ”

Replica Set

πŸ” Table of Contents πŸ”

Sharded Cluster

πŸ” Table of Contents πŸ”

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.
πŸ” Table of Contents πŸ”

Facebook Icontwitter iconlinkedin icon
Rate this quickstart
star-empty
star-empty
star-empty
star-empty
star-empty
Related
Article

Designing, Developing, and Analyzing with the New MongoDB Shell


Feb 03, 2023 | 4 min read
Quickstart

Quick Start: BSON Data Types - Decimal128


Sep 23, 2022 | 2 min read
Tutorial

Easy Migration: From Relational Database to MongoDB with MongoDB Relational Migrator


Jan 04, 2024 | 6 min read
Tutorial

Adding Real-Time Notifications to Ghost CMS Using MongoDB and Server-Sent Events


Aug 14, 2023 | 7 min read
Table of Contents