MongoDB for Developers with Python Transcripts
Chapter: MongoDB's shell and native query syntax
Lecture: Robomongo: A better shell
0:01 The shell is pretty nice and it's ubiquitous and that you can run it anywhere, you ssh to and things like that,
0:08 so that really good, and this is more or less the tools that MnongoDB ships, you could work on something else that's coming along
0:13 but there's a really great, better shell in my opinion much, much better, I really love it, it's called Robomongo,
0:20 so we talked about Robomongo in the setup how we installed it and so on, so let's see how it works and how it compares to the shell here.
0:29 So here it is, you can see it hanging out down there and we click start, maybe it's empty let's go ahead and start from scratch,
0:36 so now if we open it up it's empty, let's create a connection, I'll just call this local or whatever, and it's going to default the local host 27017,
0:46 all this stuff turned off, things like that, and we'll just say save and connect and now you can see, let's put these little more side by side,
0:54 you can see over here we have our bookstore or charge watcher and so on. And now we have the benefit that we can open this up
1:03 we can look at the book, we could say explore the indexes we could even go over and say edit this index and make changes,
1:09 make it unique, do some other things about sparseness and so on. We'll talk more about that later.
1:16 Over here, we could say something like use bookstore and it switches there,
1:20 the equivalent over here would be something like right click and say open shell,
1:24 how interesting, so I know a lot of people prefer the command line interface but what's really awesome about Robomongo is
1:32 you have the entire cli right here, so I could say something like db.Book, notice the auto completion, book, publisher, user, auth, etc,
1:43 .what do you want to find, find and modify, find one, let's find one where, what did we have before, we had something with the title
1:49 and let me go back and find the title we were using— so here we can say title like this, and now if I run it, I get a result down here
2:04 and I can explore it, I can see the ratings and so on, and this, you know if we run this over here,
2:09 I get I did the little projection, I could do that as well. So I get this text version and I actually don't really love this too much,
2:16 so you can actually just switch it to the text version here as well, and you get color coding, highlighting, all sorts of stuff.
2:23 You also get this version which is kind of a flat version, I never use this but you can use it if you want.
2:30 What is really cool is I can come over here and say I want to maybe edit this document, if I come over and do a find, I think—
2:42 here I get three, now if I do a straight find, not a find one, I can actually go and edit this, so if I wanted to change
2:47 the date that this was done on, so let's say 2011, save, rerun this, this is one with so many ratings,
3:00 here, this is the one I changed, number 2, now it's 2011. So of course I could run an update command,
3:09 but you can do all sorts of interesting sort of UI things so I really really like using Robomongo,
3:13 because it's one hundred percent as capable as the shell so for example, I could come over here, this is like just typing Mongo
3:20 you could create variables, I could say var page, let's do something with a paging here, so I come and say this
3:28 now notice, this uses get collection and it doesn't use the .Book like this,
3:33 I think it does that because it gets better intellisense or auto completion, not really sure, anyway, you can do it either way, they are equivalent.
3:42 Now, let's go over here and imagine we're going to do some paging, so first of all, let's just select the titles
3:48 remember the thing I did with the projection, exactly the same thing here, there we go, I forgot to rerun it, okay.
3:54 So rerun it, now we get just the titles, there's "Classical Mythology", "Clara Callan" and "Decision in Normandy" and so on,
4:08 so if I put some semi colons in here, I can type let's say var page size is three var page num, like what number are we on, let's say were on page two,
4:18 than down here I could say ok, this is what I want to do, and I could do skip and page to actually do the paging,
4:25 so I could say skip and we'll do what page num, minus one, times page size that's how many we want to skip,
4:35 and then we want to limit it to page size like this so now I should get, let's see, go back to the beginning,
4:42 three things per page, we're going to be on page two, so it should be the Flu, the Mummies and the Kitchen God's Wife, and that's it.
4:53 Oh, by the way if you highlight something, it just runs that expression which apparently evaluates the two, run the whole thing—
5:01 notice Flu, Mummies, Kitchen, so we can do this basically as much as we want to type up here,
5:07 but it's also a little editor, I mean just in almost every way this is better than the shell and I could even use this
5:14 to connect to my remote MongoDB server, using ssh tunneling, again, we'll talk about those kinds of things when we get to the deployment section
5:21 but for pretty much the rest of the course, we're going to be using Robomongo because it's just better in every way in my opinion.
5:29 All right, and as you saw Robomongo installs on Windows, Linux and MacOs, so it's all good.