Mongodb Cheat Sheet
As Part of Our Mongodb Guide, We’ve Compiled This Cheat Sheet of Common and Not-So-Common Mongodb Commands. (This Article Is Part of Our Mongodb Guide. Use the...
As part of our MongoDB Guide, we’ve compiled this cheat sheet of common and not-so-common MongoDB commands.
(This article is part of our MongoDB Guide. Use the right-hand menu to navigate.)
Pretty Print
Create Collection
Create Indexes
Create index
Create sparse index
Create compound index
Create geo index
Create partial index
Add and Delete Data
Add one data record
Add array (many) records
Delete data
Query MongoDB Documents
Search by attribute
Search by geolocation
Search greater or less than
Search not equal to
Search and return only certain fields
Search by regular expression
Find by elements in array
Replication and Sharding
Enable replication
Add shard
Show Server Memory
Aggregate functions
MapReduce
Pretty Print
Add pretty() to the end of any search:
db.collection.find({}).pretty()
Must Read
Create Collection
db.createCollection("<collection name>")