Instructor: Now instead of using the terminal
to work with MongoDB, we can also use an app
with a graphical user interface that MongoDB
provides us which is called Compass.
So let's now go ahead and download the Compass application.
So if you still have the page open where we downloaded
MongoDB in one of the first lectures,
you can download the Compass app right from here.
Okay, so it's then tools and Compass.
All right, and if you just opened up the MongoDB website
for the first time, then just come to products
and down here, you have MongoDB Compass.
Okay, now just download the stable version
at your time of recording then choose your platform
which in my case is Mac OS and then just download.
Now in order to download Compass,
you will need to give MongoDB some
information about you but it's really worth it,
and so I see no problem in doing that.
I'm not gonna do it here right now
because I already have Compass on my computer.
Okay, so just pause the video at this point,
fill this form then download the installator
and install it on your computer.
Then after that, come back to this video
to get started with Compass.
So when you open up the Compass application,
it should look something like this.
So right away, you should be on the screen
for creating a new connection, okay?
And if you're not then just head over here
to the left side and click new connection.
You might also have some window with some tips
that opens up the first time when you open Compass
but you can just close that away.
Okay, so that you get to this screen.
Now in order to create a connection to your local database,
make sure you have the Mongo server
running in the background, so just to make sure,
open up this process here and then here make sure
that it's still working so that it's still
on the default port of 27017.
Okay and so if you get back here, you actually already
have that automatically fill in for you.
So the Hostname is by default Localhost
and the port is 27017 just like we saw in our Mongo server.
Right, and so you actually do not have to fill anything,
all we have to do is to click connect.
All right, and so right away, here you see
all the databases that we locally have on our computer.
So here in this nice list and also here on the left side.
So, just to make sure that this is correct,
let's go to our terminal here and write,
well after deleting this here of course,
let's write show dbs and indeed these are the exact
same for databases that I have in Compass.
And again, don't worry if yours
are not exactly the same, as long as
you have the natours test databased in there, you're fine.
Okay, so we open that up
and so we have our tours collection.
And you can also see it here on the left side.
So if we open that up now, then in there
we have the two documents that we created before
in the Mongo shell right, so let's create a new one,
let's give it a name, and let's use again
The Forest Hiker, which is the one that we deleted
in the previous lecture, all right hit return,
which will then open a new line.
Let's set the price to 297, all right?
And when I was here I just hit tab
to then define the value, okay,
and then again return, rating, tab
and 4.7.
Okay, so let's insert it, or actually we should change
this here from string to a number,
so let's say an integer
and let's say here a double, insert and here we go.
So just like this we created a new document.
And of course here in the terminal,
we can just quickly confirm that, so db.tours.find,
and here we go that's our newly created
document that we just created using Compass.
So Compass is really just a graphical user interface
for doing the exact same stuff that we can do here, okay.
But of course it was very important for us to do it in code,
because that's actually how were gonna do it later
in our express application, okay?
But of course it was still very important
to also do it in code before because then it's actually
how we will do it later in our express application.
Anyway, let's now go back here
and for example, edit some stuff here.
So we have here on the right side these buttons to edit,
and so we can simply, let's say change the price here to 997
for example, and then hit update down here and here we go.
We can also delete documents,
so let's get rid of the one we just did before.
Okay and of course we can also query for documents
and we do that up here.
And here we actually need to write
the kind of code that we wrote before.
So for example, let's search for tours
with a price less than 700.
And so, again that works just like
we did it before in the terminal.
Okay so, in the Mongo shell.
So, we want the price to be less than,
700.
And you see here that Compass actually
did a lot of auto suggestions here,
so let's see that again.
So it gives us right away lt and lte here.
And in this case, doesn't really matter.
So close that guy and close this one.
And you see that before it was red,
so meaning that the query was not valid,
and also the button was not clickable.
But now, when it's correct, we just need to hit return
and then it gives us all the documents that match our query.
In this case, it's just this one, but of course
if there were multiple, then all of them would get matched.
And here we could also do the project, and remember
that project means to just select some of the fields.
And so let's say,
name set to one, and so we only get the name now.
Right, remember doing that in one
of the Mongo shell lectures, okay.
Finally, we can then reset all of this
and get rid of our queries
and get back to our initial state.
And here in Compass we can really do all kinds of stuff.
Aggregations, define some schemas or analyze schemas,
take look at indexes and all that good stuff
that we're gonna do throughout the course.
Okay, so we're gonna do aggregations,
we're gonna analyze our schema, we're gonna create indexes,
we're gonna create validation and so really
as you can see there's a lot of content ahead of us.