MongoDB comes with an interactive shell, which we have already used briefly in the previous chapter. To refresh your memory, after starting the MongoDB daemon by typing mongod
, you access the shell in a separate terminal window by typing mongo
.
Primarily, you will be accessing MongoDB using native code in your application. However, understanding the MongoDB shell is invaluable to using it. There will be times when you want to access the shell directly, particularly for debugging. You may also need to manage a MongoDB instance in the cloud.
You should have a good grasp of the MongoDB shell.
One of the most important things you can do in the MongoDB shell is to manage your databases. Getting meta information out of MongoDB is most easily accomplished using shell commands. The following are some of the basic commands you can use in the MongoDB shell to get information.
help
- This will output a list of basic commands available in the MongoDB shell. For help...