Yes, to display a database in the list, first create a database and add collection(s), else it won’t be visible in the list. After that, use the SHOW dbs command to display the database name in the list of databases.
Following is the query to create a database −
> use webcustomertracker; switched to db webcustomertracker
Let us first create a collection with documents −
> db.first_Collection.insert({"Name":"Chris"}); WriteResult({ "nInserted" : 1 })
Following is the query to display all documents from a collection with the help of find() method −
> db.first_Collection.find();
This will produce the following output −
{ "_id" : ObjectId("5ce2760836e8b255a5eee94a"), "Name" : "Chris" }
Following is the query to display your creating database −
> show dbs;
This will produce the following output −
admin 0.002GB business 0.000GB config 0.000GB local 0.000GB main 0.000GB my 0.001GB sample 0.002GB sampleDemo 0.000GB studentSearch 0.000GB test 0.019GB university 0.000GB web 0.001GB webcustomertracker 0.000GB