Using the MongoDB Shell
It’s worth getting to know about the MongoDB
Running shell commands with MongoDB is a really useful way to quickly check what’s in your database. You can review and update your database contents directly from the command line.
Make sure the MongoDB database is running before attempting to start the
mongo shell. To start up the database, run
./mongod. You should see something like this:
To start a shell prompt for the above MongoDB, open a new terminal and type the command
mongo to initialize the shell.
With the shell running, I can list the available databases with the command
show databases. I can see listed the database I’ve been using:
I can switch to this database with the command:
Now I can have a look at the collections in the database with:
I haven’t been too busy - there are just two collections so far.
I can see exactly what’s in the storedLinks collection by running a
find() method on it without any arguments. This returns everything:
There’s a multitude of entries in the collection with the same URL that I entered while testing the interface. This is useful to know!