Commands

The mongo shell is an interactive JavaScript environment. Much like the console in a web browser, where you can execute pieces of JavaScript. However, the mongo shell is used to interact with the mongod server application. Commands can be issued to perform operations, fetch data.

db - Display the current database being used

$ mongo
> db
test

show dbs - Show all the databases (helper)

> db
test
> show dbs
local  0.000GB
test   0.000GB

show collections - Show all the collections in the current database

> db
test
> show collections
> show collections
friends
myCollection
users
`

use {database-name} - Swtch to a specific database (helper)

$ mongo
> use users
switched to db users

Note: We can switch to a non existing database. Only when data is inserted into a collection, does the database take shape.