1 00:00:02,620 --> 00:00:08,860 So over the last lectures, we talked a lot about the mongodb server and its options. In this lecture, 2 00:00:08,860 --> 00:00:14,790 I also want to touch on the Mongo shell, which options do we have on the Mongo shell? 3 00:00:15,160 --> 00:00:23,450 Well just as you could type mongod --help, you can type mongo --help, 4 00:00:23,450 --> 00:00:30,560 so now the help options for the Mongo shell and there, you see it has way less options because 5 00:00:30,560 --> 00:00:33,680 it's just a connecting client in the end, not the server. 6 00:00:34,040 --> 00:00:39,230 You can for example run it without connecting to a database because the shell is based on javascript 7 00:00:39,230 --> 00:00:43,240 so if you just want to execute some javascript code, you could do that, 8 00:00:43,280 --> 00:00:48,120 you can also run it in quiet mode to output less information, 9 00:00:48,530 --> 00:00:53,530 you can define a port and a host for the server to which it should try to connect, 10 00:00:53,540 --> 00:00:57,200 by default it takes localhost 27017 11 00:00:57,380 --> 00:01:02,510 but if you run your mongodb server on a different host and we'll do this by the end of the 12 00:01:02,510 --> 00:01:02,840 course, 13 00:01:02,840 --> 00:01:10,250 I will show you how to create a mongodb set up in the cloud or on a real server, not an our machine, 14 00:01:10,430 --> 00:01:14,510 so if you want to connect to something like this then you can do this with port and host, so that you 15 00:01:14,510 --> 00:01:17,840 don't try to connect to the local host. 16 00:01:17,870 --> 00:01:20,690 You can set up some SSL settings which I don't need here 17 00:01:20,840 --> 00:01:26,600 and later once we add authentication, we also can add our authentication information, we'll see that 18 00:01:26,630 --> 00:01:28,450 later in the course too. 19 00:01:28,460 --> 00:01:30,390 So right now, there isn't really an option 20 00:01:30,410 --> 00:01:34,670 I would need to execute but there is also something interesting inside of the shell, 21 00:01:34,670 --> 00:01:43,670 so after you started it and connect it. In there, you can type help like this and help will output a short 22 00:01:43,670 --> 00:01:46,590 list of some important help information, 23 00:01:46,610 --> 00:01:52,490 some important commands you can execute and you can even dive into detailed help like for example what 24 00:01:52,490 --> 00:01:55,060 can I do as an admin by typing help admin 25 00:01:55,160 --> 00:02:01,270 and now you see a couple of commands that might be useful when it comes to administrating the database. 26 00:02:01,280 --> 00:02:08,440 Now back to just help, you see here are the show dbs and the show collections commands we used before, 27 00:02:08,810 --> 00:02:13,040 you also see for example how you find all objects in a collection, 28 00:02:13,080 --> 00:02:14,810 also not that bad to know 29 00:02:15,170 --> 00:02:23,020 and you can also output help for a given database or a collection in a database, like here 30 00:02:23,300 --> 00:02:31,280 if I have a look at my databases, I got no database set up here or no database besides the default databases. 31 00:02:31,280 --> 00:02:38,810 Now if I use my test database and I type db help, I see commands that I can run here on the database 32 00:02:39,300 --> 00:02:42,450 and you see there are a lot of commands you never saw before, 33 00:02:42,470 --> 00:02:48,410 a lot of commands you don't really need but there also are commands like create collection which we 34 00:02:48,410 --> 00:02:50,520 already did use in this course. 35 00:02:51,320 --> 00:02:58,100 You see there also are commands for dropping the database for example or for getting all kinds of information. 36 00:02:58,260 --> 00:03:03,770 Now these are commands you also find in the official docs if you want to learn more about them 37 00:03:03,800 --> 00:03:10,200 and as I said a lot of them are commands you will probably never need but still nice to know these commands, 38 00:03:10,280 --> 00:03:13,040 db run command is another command we saw earlier 39 00:03:13,040 --> 00:03:14,520 for example. 40 00:03:14,780 --> 00:03:17,030 Now we can also get help on the collection level, 41 00:03:17,030 --> 00:03:19,830 let's say I would have a test collection in there, 42 00:03:20,030 --> 00:03:21,620 I can run help like this 43 00:03:21,680 --> 00:03:28,940 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 44 00:03:28,940 --> 00:03:31,870 all the commands I can execute directly on the collection 45 00:03:32,090 --> 00:03:35,440 and these are all the insert or find commands for example 46 00:03:35,570 --> 00:03:38,930 but you also have some other commands like the stats for this collection 47 00:03:38,930 --> 00:03:40,320 if you're interested in this. 48 00:03:40,490 --> 00:03:43,850 So these are a lot of nice to know features, 49 00:03:43,850 --> 00:03:49,460 you can definitely play around with them and just execute a couple of these commands, if possible in 50 00:03:49,460 --> 00:03:51,700 a database and collection where it doesn't hurt 51 00:03:51,740 --> 00:03:54,840 if you mess up things but you can play around with that, 52 00:03:54,980 --> 00:03:57,540 this is how you can find help. And with that, 53 00:03:57,560 --> 00:04:04,220 together with your log files and the official docs and Google as always, you should of course be able to get 54 00:04:04,220 --> 00:04:10,640 the most out of mongodb and fix potential issues or find that special feature you're looking for.