0% found this document useful (0 votes)
22 views

Mongodb Cheat Sheet - : DB - Movie.Find ( (Name: "Grantorino") ) .Foreach (Printjson)

This document provides a cheat sheet for common MongoDB commands, including how to start and stop the MongoDB service, open the mongo shell, check databases and collections, insert and find documents, and filter output. Key commands covered are starting and stopping MongoDB, opening the mongo shell, checking databases and collections, inserting documents into a collection, finding all or filtered documents, and dropping databases.

Uploaded by

pratik roy
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Mongodb Cheat Sheet - : DB - Movie.Find ( (Name: "Grantorino") ) .Foreach (Printjson)

This document provides a cheat sheet for common MongoDB commands, including how to start and stop the MongoDB service, open the mongo shell, check databases and collections, insert and find documents, and filter output. Key commands covered are starting and stopping MongoDB, opening the mongo shell, checking databases and collections, inserting documents into a collection, finding all or filtered documents, and dropping databases.

Uploaded by

pratik roy
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1

MongoDB CHEAT SHEET

-----------------------------------

• Start MongoDB: sudo service mongodb start


• Stop MongoDB: sudo service mongodb stop
• Restart MongoDB: sudo service mongodb restart
• Start Mongo Shell: mongo
• Start Mongo Shell on a Port: mongo --port 2805
• MongoDB Help: db.help()
• MongoDB Statistics: db.stats()
• create database: use DATABASE_NAME
• Check DB you are in: db
• check your databases list: show dbs
• Insert command: db.movie.insert({"name":"tutorials point"})
• drop a existing database: use mydb; db.dropDatabase()
• create a collection: db.createCollection(name,options)
• show collections: show collections
• insert document: db.movie.insert({"name": "Grantorino"})
• Get all documents: db.movie.find().forEach(printjson)
• Filter Output: db.movie.find({name :
"Grantorino"}).forEach(printjson);

You might also like