MongoDB Cheat Sheet
Transform, format, and optimize your data instantly with this free client-side tool.
Database
Switch to or create a database
List all databases
Show current database
Drop the current database
Get database statistics
Collection
List all collections in current database
Explicitly create a collection
Drop the specified collection
Get collection statistics
Rename a collection
Create
Insert a single document into collection
Insert multiple documents
Read (Queries)
Find all documents in collection
Find a single document
Find documents matching condition
Format the output for readability
Find documents where k > 5
Find documents where k is in array
Query using regular expressions
Find documents matching either condition
Projection: Return only 'name' field, exclude '_id'
Update
Update first matching document
Update all matching documents
Replace the entire document
Increment a numeric field
Remove a field from document
Append value to an array
Remove value from an array
Update or insert if document doesn't exist
Delete
Delete first document matching query
Delete all documents matching query
Delete all documents in collection (truncate)
Modifiers
Count the number of documents returned
Limit the number of returned documents
Skip the first 5 documents
Sort results (1 for ascending, -1 for descending)
Aggregation
Filter documents in pipeline
Group documents and calculate sum
Sort grouped results
Reshape documents and add fields
Indexes
Create an index on field 'k'
Create a unique index
List all indexes on collection
Drop a specific index
Administration
Create a new user with roles
Authenticate with database
View currently running operations
Kill a running operation
Advanced
Explore advanced configurations for Mongo
Performance tuning best practices for Mongo
Run security checks and validation for Mongo
🔥 Similar Tools
Explore LibraryFrequently Asked Questions
Got questions? We've got answers.