Description | Command |
---|---|
Show All Databases | show dbs |
Show Current Database | db |
Create Or Switch Database | use acme |
Drop | db.dropDatabase() |
Create Collection | db.createCollection('posts') |
Show Collections | show collections |
Get All Rows | db.posts.find() |
Get All Rows Formatted | db.find().pretty() |
Find Rows | db.posts.find({ category: 'News' }) |
Sort Rows | asc: db.posts.find().sort({ title: 1 }).pretty() desc: db.posts.find().sort({ title: -1 }).pretty() |
Count Rows | db.posts.find().count() db.posts.find({ category: 'news' }).count() |
Limit Rows | db.posts.find().limit(2).pretty() |
Chaining | db.posts.find().limit(2).sort({ title: 1 }).pretty() |
Foreach | db.posts.find().forEach(function(doc) { print('Blog Post: ' + doc.title)}) |
Find One Row | db.posts.findOne({ category: 'News' }) |
Find Specific Fields | db.posts.find({ title: 'Post One' }, { title: 1, author: 1}) |
Delete Row | db.posts.remove({ title: 'Post Four' }) |
Add Index | db.posts.createIndex({ title: 'text' }) |
Containers Cheat Sheet. Introduction to Container architecture. Engine, image, registry, volume, related commands. Example of running a web server container. MongoDB Cheat Sheet. MongoDB Commands Cheat Sheet for Beginners By Ajitesh Kumar on July 6, 2018 MongoDB, NoSQL In this post, you will learn about MongoDB commands which could get you started and perform minimum database related activities such as create, update, drop a collection (table). The above mongo command only works if your MongoDB server runs on the default port, which is 27017. If your MongoDB server runs on a different port, you have to explicitly specify it in the command, as shown below: mongo -port 28010 Remote server. Both of the above commands only work if your MongoDB server is running on the localhost. MongoDB Commands Listing (Administrative Command Helpers): The sections above provide helpful commands that can get you online on MongoDB and do some administrative tasks on MongoDB. This section specifically works upon the administrative tasks on databases created within the MongoDB database server.
Insert Row¶
Insert Multiple Rows¶
Update Row¶
Update Specific Field¶
Increment Field ($inc)¶


Rename Field¶
Sub-Documents¶
Find By Element in Array ($elemMatch)¶

Text Search¶
Greater & Less Than¶
-->APPLIES TO: SQL API
The Azure Cosmos DB query cheat sheets help you quickly write queries for your data by displaying common database queries, operations, functions, and operators in easy-to-print PDF reference sheets. The cheat sheets include reference information for the SQL, MongoDB, Table, and Gremlin APIs.
Choose from a letter-sized or A3-sized download.
Pymongo Cheat Sheet
Letter-sized cheat sheets
Mongodb Command Shell
Download the Azure Cosmos DB letter-sized query cheat sheets if you're going to print to letter-sized paper (8.5' x 11').
Oversized cheat sheets
Mongodb Commands Cheat Sheet Examples
Download the Azure Cosmos DB A3-sized query cheat sheets if you're going to print using a plotter or large-scale printer on A3-sized paper (11.7' x 16.5').
Next steps
For more help writing queries, see the following articles:
- For SQL API queries, see Query using the SQL API, SQL queries for Azure Cosmos DB, and SQL syntax reference
- For MongoDB queries, see Query using Azure Cosmos DB's API for MongoDB and Azure Cosmos DB's API for MongoDB feature support and syntax
- For Gremlin API queries, see Query using the Gremlin API and Azure Cosmos DB Gremlin graph support
- For Table API queries, see Query using the Table API
