﻿1
00:00:01,160 --> 00:00:02,980
‫Now instead of using the terminal

2
00:00:02,980 --> 00:00:05,972
‫to work with MongoDB, we can also use an app

3
00:00:05,972 --> 00:00:09,290
‫with a graphical user interface that MongoDB

4
00:00:09,290 --> 00:00:11,123
‫provides us which is called Compass.

5
00:00:12,010 --> 00:00:16,143
‫So let's now go ahead and download the Compass application.

6
00:00:18,000 --> 00:00:20,820
‫So if you still have the page open where we downloaded

7
00:00:20,820 --> 00:00:23,180
‫MongoDB in one of the first lectures,

8
00:00:23,180 --> 00:00:26,050
‫you can download the Compass app right from here.

9
00:00:26,050 --> 00:00:28,693
‫Okay, so it's then tools and Compass.

10
00:00:29,880 --> 00:00:33,030
‫All right, and if you just opened up the MongoDB website

11
00:00:33,030 --> 00:00:36,250
‫for the first time, then just come to products

12
00:00:36,250 --> 00:00:39,360
‫and down here, you have MongoDB Compass.

13
00:00:39,360 --> 00:00:43,008
‫Okay, now just download the stable version

14
00:00:43,008 --> 00:00:46,320
‫at your time of recording then choose your platform

15
00:00:46,320 --> 00:00:50,570
‫which in my case is Mac OS and then just download.

16
00:00:50,570 --> 00:00:52,350
‫Now in order to download Compass,

17
00:00:52,350 --> 00:00:54,400
‫you will need to give MongoDB some

18
00:00:54,400 --> 00:00:57,060
‫information about you but it's really worth it,

19
00:00:57,060 --> 00:00:59,170
‫and so I see no problem in doing that.

20
00:00:59,170 --> 00:01:00,760
‫I'm not gonna do it here right now

21
00:01:00,760 --> 00:01:03,710
‫because I already have Compass on my computer.

22
00:01:03,710 --> 00:01:06,225
‫Okay, so just pause the video at this point,

23
00:01:06,225 --> 00:01:09,680
‫fill this form then download the installator

24
00:01:09,680 --> 00:01:12,120
‫and install it on your computer.

25
00:01:12,120 --> 00:01:14,900
‫Then after that, come back to this video

26
00:01:14,900 --> 00:01:16,333
‫to get started with Compass.

27
00:01:19,600 --> 00:01:22,090
‫So when you open up the Compass application,

28
00:01:22,090 --> 00:01:23,980
‫it should look something like this.

29
00:01:23,980 --> 00:01:26,410
‫So right away, you should be on the screen

30
00:01:26,410 --> 00:01:29,010
‫for creating a new connection, okay?

31
00:01:29,010 --> 00:01:31,190
‫And if you're not then just head over here

32
00:01:31,190 --> 00:01:33,640
‫to the left side and click new connection.

33
00:01:33,640 --> 00:01:35,943
‫You might also have some window with some tips

34
00:01:35,943 --> 00:01:38,630
‫that opens up the first time when you open Compass

35
00:01:38,630 --> 00:01:41,060
‫but you can just close that away.

36
00:01:41,060 --> 00:01:43,930
‫Okay, so that you get to this screen.

37
00:01:43,930 --> 00:01:47,260
‫Now in order to create a connection to your local database,

38
00:01:47,260 --> 00:01:49,460
‫make sure you have the Mongo server

39
00:01:49,460 --> 00:01:53,480
‫running in the background, so just to make sure,

40
00:01:53,480 --> 00:01:56,175
‫open up this process here and then here make sure

41
00:01:56,175 --> 00:01:59,140
‫that it's still working so that it's still

42
00:01:59,140 --> 00:02:01,973
‫on the default port of 27017.

43
00:02:03,631 --> 00:02:06,700
‫Okay and so if you get back here, you actually already

44
00:02:06,700 --> 00:02:09,150
‫have that automatically fill in for you.

45
00:02:09,150 --> 00:02:11,687
‫So the Hostname is by default Localhost

46
00:02:11,687 --> 00:02:16,687
‫and the port is 27017 just like we saw in our Mongo server.

47
00:02:17,130 --> 00:02:20,025
‫Right, and so you actually do not have to fill anything,

48
00:02:20,025 --> 00:02:22,868
‫all we have to do is to click connect.

49
00:02:22,868 --> 00:02:25,864
‫All right, and so right away, here you see

50
00:02:25,864 --> 00:02:29,524
‫all the databases that we locally have on our computer.

51
00:02:29,524 --> 00:02:33,800
‫So here in this nice list and also here on the left side.

52
00:02:33,800 --> 00:02:36,500
‫So, just to make sure that this is correct,

53
00:02:36,500 --> 00:02:39,873
‫let's go to our terminal here and write,

54
00:02:40,840 --> 00:02:43,650
‫well after deleting this here of course,

55
00:02:43,650 --> 00:02:48,650
‫let's write show dbs and indeed these are the exact

56
00:02:48,680 --> 00:02:51,880
‫same for databases that I have in Compass.

57
00:02:51,880 --> 00:02:53,710
‫And again, don't worry if yours

58
00:02:53,710 --> 00:02:55,730
‫are not exactly the same, as long as

59
00:02:55,730 --> 00:02:59,970
‫you have the natours test databased in there, you're fine.

60
00:02:59,970 --> 00:03:02,330
‫Okay, so we open that up

61
00:03:02,330 --> 00:03:04,650
‫and so we have our tours collection.

62
00:03:04,650 --> 00:03:07,440
‫And you can also see it here on the left side.

63
00:03:07,440 --> 00:03:09,830
‫So if we open that up now, then in there

64
00:03:09,830 --> 00:03:12,510
‫we have the two documents that we created before

65
00:03:12,510 --> 00:03:16,710
‫in the Mongo shell right, so let's create a new one,

66
00:03:16,710 --> 00:03:19,160
‫let's give it a name, and let's use again

67
00:03:19,160 --> 00:03:22,890
‫The Forest Hiker, which is the one that we deleted

68
00:03:22,890 --> 00:03:25,771
‫in the previous lecture, all right hit return,

69
00:03:25,771 --> 00:03:28,570
‫which will then open a new line.

70
00:03:28,570 --> 00:03:32,630
‫Let's set the price to 297, all right?

71
00:03:32,630 --> 00:03:34,890
‫And when I was here I just hit tab

72
00:03:34,890 --> 00:03:37,450
‫to then define the value, okay,

73
00:03:37,450 --> 00:03:41,500
‫and then again return, rating, tab

74
00:03:41,500 --> 00:03:43,810
‫and 4.7.

75
00:03:43,810 --> 00:03:47,940
‫Okay, so let's insert it, or actually we should change

76
00:03:47,940 --> 00:03:50,810
‫this here from string to a number,

77
00:03:50,810 --> 00:03:54,340
‫so let's say an integer

78
00:03:54,340 --> 00:03:59,340
‫and let's say here a double, insert and here we go.

79
00:03:59,910 --> 00:04:03,490
‫So just like this we created a new document.

80
00:04:03,490 --> 00:04:05,260
‫And of course here in the terminal,

81
00:04:05,260 --> 00:04:10,260
‫we can just quickly confirm that, so db.tours.find,

82
00:04:12,630 --> 00:04:15,800
‫and here we go that's our newly created

83
00:04:15,800 --> 00:04:19,080
‫document that we just created using Compass.

84
00:04:19,080 --> 00:04:22,200
‫So Compass is really just a graphical user interface

85
00:04:22,200 --> 00:04:26,160
‫for doing the exact same stuff that we can do here, okay.

86
00:04:26,160 --> 00:04:29,400
‫But of course it was very important for us to do it in code,

87
00:04:29,400 --> 00:04:31,455
‫because that's actually how were gonna do it later

88
00:04:31,455 --> 00:04:34,205
‫in our express application, okay?

89
00:04:34,205 --> 00:04:36,690
‫But of course it was still very important

90
00:04:36,690 --> 00:04:40,330
‫to also do it in code before because then it's actually

91
00:04:40,330 --> 00:04:43,450
‫how we will do it later in our express application.

92
00:04:43,450 --> 00:04:45,623
‫Anyway, let's now go back here

93
00:04:45,623 --> 00:04:49,540
‫and for example, edit some stuff here.

94
00:04:49,540 --> 00:04:53,270
‫So we have here on the right side these buttons to edit,

95
00:04:53,270 --> 00:04:58,270
‫and so we can simply, let's say change the price here to 997

96
00:04:58,750 --> 00:05:03,610
‫for example, and then hit update down here and here we go.

97
00:05:03,610 --> 00:05:06,220
‫We can also delete documents,

98
00:05:06,220 --> 00:05:08,973
‫so let's get rid of the one we just did before.

99
00:05:10,150 --> 00:05:13,940
‫Okay and of course we can also query for documents

100
00:05:13,940 --> 00:05:15,780
‫and we do that up here.

101
00:05:15,780 --> 00:05:17,120
‫And here we actually need to write

102
00:05:17,120 --> 00:05:19,530
‫the kind of code that we wrote before.

103
00:05:19,530 --> 00:05:21,870
‫So for example, let's search for tours

104
00:05:21,870 --> 00:05:24,200
‫with a price less than 700.

105
00:05:24,200 --> 00:05:26,611
‫And so, again that works just like

106
00:05:26,611 --> 00:05:30,100
‫we did it before in the terminal.

107
00:05:30,100 --> 00:05:32,430
‫Okay so, in the Mongo shell.

108
00:05:32,430 --> 00:05:35,923
‫So, we want the price to be less than,

109
00:05:37,150 --> 00:05:38,030
‫700.

110
00:05:38,030 --> 00:05:40,240
‫And you see here that Compass actually

111
00:05:40,240 --> 00:05:42,970
‫did a lot of auto suggestions here,

112
00:05:42,970 --> 00:05:44,880
‫so let's see that again.

113
00:05:44,880 --> 00:05:47,733
‫So it gives us right away lt and lte here.

114
00:05:49,110 --> 00:05:50,930
‫And in this case, doesn't really matter.

115
00:05:50,930 --> 00:05:53,570
‫So close that guy and close this one.

116
00:05:53,570 --> 00:05:55,480
‫And you see that before it was red,

117
00:05:55,480 --> 00:05:57,990
‫so meaning that the query was not valid,

118
00:05:57,990 --> 00:06:00,600
‫and also the button was not clickable.

119
00:06:00,600 --> 00:06:05,060
‫But now, when it's correct, we just need to hit return

120
00:06:05,060 --> 00:06:08,500
‫and then it gives us all the documents that match our query.

121
00:06:08,500 --> 00:06:11,200
‫In this case, it's just this one, but of course

122
00:06:11,200 --> 00:06:15,750
‫if there were multiple, then all of them would get matched.

123
00:06:15,750 --> 00:06:18,890
‫And here we could also do the project, and remember

124
00:06:18,890 --> 00:06:22,970
‫that project means to just select some of the fields.

125
00:06:22,970 --> 00:06:23,973
‫And so let's say,

126
00:06:25,600 --> 00:06:30,600
‫name set to one, and so we only get the name now.

127
00:06:30,730 --> 00:06:32,810
‫Right, remember doing that in one

128
00:06:32,810 --> 00:06:35,480
‫of the Mongo shell lectures, okay.

129
00:06:35,480 --> 00:06:37,720
‫Finally, we can then reset all of this

130
00:06:38,560 --> 00:06:40,020
‫and get rid of our queries

131
00:06:40,020 --> 00:06:42,350
‫and get back to our initial state.

132
00:06:42,350 --> 00:06:45,270
‫And here in Compass we can really do all kinds of stuff.

133
00:06:45,270 --> 00:06:49,500
‫Aggregations, define some schemas or analyze schemas,

134
00:06:49,500 --> 00:06:52,290
‫take look at indexes and all that good stuff

135
00:06:52,290 --> 00:06:54,380
‫that we're gonna do throughout the course.

136
00:06:54,380 --> 00:06:56,350
‫Okay, so we're gonna do aggregations,

137
00:06:56,350 --> 00:06:59,780
‫we're gonna analyze our schema, we're gonna create indexes,

138
00:06:59,780 --> 00:07:02,490
‫we're gonna create validation and so really

139
00:07:02,490 --> 00:07:05,673
‫as you can see there's a lot of content ahead of us.

