Mongo Shell

  1. It is a component of MongoDB
  2. Shell provides an interactive javascript interface.
  3. The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mongo shell to query and update data as well as perform administrative operations.
  4. In windows to use mongo shell find mongo.exe and run it.
  5. To start or work on the shell you need to start mongod.exe which is present on installation path of C:\Program Files\MongoDB\Server\4.0\bin
Sagar-Jaybhay-MongoDb-Shell
  1. Crud operation is perform using mongo shell and also it provides support for JavaScript. It means you can use JavaScript functions or JavaScript code for that.

Mongodb shell commands you can found on this link

Command Helpers

Sagar_Jaybhay-Mongo-Command-Helper-1
Sagar-Jaybhay-MongoDB-Command-helper-2

Commands Explain

Help to get help and show commands on the console

Sagar-Jaybhay-Help-Command

Shortcut to clear mongo screen ctrl + l

  1. List of databases: show DBS
Sagar-Jaybhay-Show-DBs

Show the collections in databases use: Show collections

If your DB is not selected then it showing blank for that you can first select the database by using this command Use database databasename / use database name to select the database.

Sagar-Jaybhay-USE-Collection

Use DatabaseName:- this command is used to switch the database if already present else it will create the database for you. But when you used show DBS command after that it will not show the newly created database. For this purpose, we have to add collection into that newly created database.

  1. JavaScript equivalent command for getting collection names of current database is db.getCollectionNames()
  2. Default collection created by mongodb is system.Indexes.
  3. You can create javascript functions using the mongo shell and called by using function name.

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer at Software Company. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

Sagar Jaybhay

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer at Software Company. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *