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 29, 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

Real-Time Location Updates with MongoDB Stitch, Change Streams, and Mapbox


Feb 03, 2023 | 5 min read
Quickstart

Quick Start: BSON Data Types - Date


Sep 23, 2022 | 2 min read
Quickstart

5 Different Ways to Deploy a Free Database with MongoDB Atlas


Feb 03, 2023 | 5 min read
Tutorial

Create a RESTful API with .NET Core and MongoDB


Jun 04, 2024 | 8 min read
Table of Contents