So over the last lectures, we talked a lot about the mongodb server and its options. In this lecture,
I also want to touch on the Mongo shell, which options do we have on the Mongo shell?
Well just as you could type mongod --help, you can type mongo --help,
so now the help options for the Mongo shell and there, you see it has way less options because
it's just a connecting client in the end, not the server.
You can for example run it without connecting to a database because the shell is based on javascript
so if you just want to execute some javascript code, you could do that,
you can also run it in quiet mode to output less information,
you can define a port and a host for the server to which it should try to connect,
by default it takes localhost 27017
but if you run your mongodb server on a different host and we'll do this by the end of the
course,
I will show you how to create a mongodb set up in the cloud or on a real server, not an our machine,
so if you want to connect to something like this then you can do this with port and host, so that you
don't try to connect to the local host.
You can set up some SSL settings which I don't need here
and later once we add authentication, we also can add our authentication information, we'll see that
later in the course too.
So right now, there isn't really an option
I would need to execute but there is also something interesting inside of the shell,
so after you started it and connect it. In there, you can type help like this and help will output a short
list of some important help information,
some important commands you can execute and you can even dive into detailed help like for example what
can I do as an admin by typing help admin
and now you see a couple of commands that might be useful when it comes to administrating the database.
Now back to just help, you see here are the show dbs and the show collections commands we used before,
you also see for example how you find all objects in a collection,
also not that bad to know
and you can also output help for a given database or a collection in a database, like here
if I have a look at my databases, I got no database set up here or no database besides the default databases.
Now if I use my test database and I type db help, I see commands that I can run here on the database
and you see there are a lot of commands you never saw before,
a lot of commands you don't really need but there also are commands like create collection which we
already did use in this course.
You see there also are commands for dropping the database for example or for getting all kinds of information.
Now these are commands you also find in the official docs if you want to learn more about them
and as I said a lot of them are commands you will probably never need but still nice to know these commands,
db run command is another command we saw earlier
for example.
Now we can also get help on the collection level,
let's say I would have a test collection in there,
I can run help like this
and note the parentheses which we also had to use on db help, so I can also run help on this and now I see
all the commands I can execute directly on the collection
and these are all the insert or find commands for example
but you also have some other commands like the stats for this collection
if you're interested in this.
So these are a lot of nice to know features,
you can definitely play around with them and just execute a couple of these commands, if possible in
a database and collection where it doesn't hurt
if you mess up things but you can play around with that,
this is how you can find help. And with that,
together with your log files and the official docs and Google as always, you should of course be able to get
the most out of mongodb and fix potential issues or find that special feature you're looking for.