ref – https://www.tutorialspoint.com/mongodb/mongodb_create_database.htm
MongoDB’s
use some DB name is used to create database. The command will create a new database if it doesn’t exist, otherwise it will return the existing database.
1 2 |
>use portfolio switched to db portfolio |
However, you must have at least 1 document in your DB before it shows up in the list. So we create one collection and insert 1 document in order for the DB to exist.
1 |
db.transfers.insert({"money", "$1000"}) |
WriteResult({ “nInserted” : 1 })
show dbs
and you’ll see database portfolio listed.