1 00:00:00,680 --> 00:00:04,750 In the last section we had a quick discussion about mongoose and Lango DVH. 2 00:00:04,890 --> 00:00:10,260 We're now going to continue by setting up a mongo DV database and wiring it together with our express 3 00:00:10,260 --> 00:00:11,760 application. 4 00:00:11,760 --> 00:00:16,650 Now in general there's two different ways that you can get longer to be running for your own personal 5 00:00:16,650 --> 00:00:17,800 projects. 6 00:00:17,850 --> 00:00:24,090 You can either install a local copy so like install a copy of Mago D-B onto your own personal laptop 7 00:00:24,090 --> 00:00:28,780 or desktop or you can use a remotely hosted instance. 8 00:00:28,830 --> 00:00:30,650 Now in this course we're going to use the latter. 9 00:00:30,660 --> 00:00:34,190 We're going to use a remotely hosted instance of Mongo DVH. 10 00:00:34,290 --> 00:00:41,520 The reason for that is that it is far easier to install Mongo D-B or to get a copy of it running when 11 00:00:41,520 --> 00:00:43,830 it is remotely hosted. 12 00:00:43,830 --> 00:00:49,590 Trust me I have helped people install and troubleshoot Mongo installations for a long time now and it 13 00:00:49,590 --> 00:00:51,200 can be a real pain in the rear. 14 00:00:51,210 --> 00:00:54,700 Sometimes it goes really well but sometimes it can be a pain in the rear. 15 00:00:54,720 --> 00:01:01,350 So in this course we're going to use a outside service or a third party service to host a copy of Mongo 16 00:01:01,350 --> 00:01:02,590 divi for us. 17 00:01:02,910 --> 00:01:09,960 So on this remote service somewhere out on the internet we will have our running Mongo DB copy and then 18 00:01:10,020 --> 00:01:11,970 on our own local computer. 19 00:01:12,090 --> 00:01:17,730 We will continue to have our express API and pretty soon we will also have our re-act application as 20 00:01:17,730 --> 00:01:18,910 well. 21 00:01:18,930 --> 00:01:24,360 Now of course this is talking about power application is set up for our development environment and 22 00:01:24,360 --> 00:01:28,110 this entire process works just a little bit differently with Heroku. 23 00:01:28,110 --> 00:01:32,670 By the way as soon as we finished wiring up all this Mongo DB stuff and we finish up the authentication 24 00:01:32,670 --> 00:01:38,580 piece we will then redeploy our application up to Trochu and get an updated copy up there. 25 00:01:39,240 --> 00:01:40,430 OK so let's get to it. 26 00:01:40,440 --> 00:01:45,680 We're going to now create a remotely hosted copy of Mongo to do so. 27 00:01:45,750 --> 00:01:52,240 I'm going to open up a new tab inside my browser and navigate to in lab dot com him. 28 00:01:52,260 --> 00:01:54,430 As in like Mongo. 29 00:01:54,690 --> 00:02:01,560 I guess now once you come here if you've never signed up for in lab before you'll want to go to the 30 00:02:01,560 --> 00:02:07,620 sign up button right here and create a brand new account absolutely no credit card is required to sign 31 00:02:07,620 --> 00:02:14,070 up for in lab or created a mongo DB database which makes in lab a really great place to get started. 32 00:02:14,220 --> 00:02:21,000 Now once you have created your account you'll want to log in and I'm going to do that right now and 33 00:02:21,000 --> 00:02:26,520 then after you sign in you'll be dumped at a dashboard that lists all of your different running Mongo 34 00:02:26,520 --> 00:02:33,540 D-B deployments and so these are a couple other copies among OODB that have running on this kind of 35 00:02:33,660 --> 00:02:35,790 test account right here. 36 00:02:35,790 --> 00:02:41,550 So chances are you don't see any of this right now because you might have never created a database previously. 37 00:02:41,550 --> 00:02:48,600 So to create a new database going to find the create new button over here will click it and it will 38 00:02:48,590 --> 00:02:50,680 be taken into a creation wizard. 39 00:02:50,970 --> 00:02:58,530 Never going to be immediately asked on what plan type we want so we can pick free $15 or a hundred and 40 00:02:58,560 --> 00:03:04,430 eighty and I'm going to let you guess which one we want. 41 00:03:04,800 --> 00:03:07,840 Yes we want the free ones are in a pick sandbox right now. 42 00:03:07,890 --> 00:03:10,980 Google club platform and Microsoft azer. 43 00:03:11,040 --> 00:03:15,140 If you want to go with these different providers you certainly can feel free to do so. 44 00:03:15,330 --> 00:03:19,430 But Amazon Web Services is totally fine. 45 00:03:19,440 --> 00:03:20,810 Totally appropriate for what we're doing. 46 00:03:20,820 --> 00:03:24,510 So we're going to pick a sandbox on AWOS. 47 00:03:24,630 --> 00:03:27,260 Now once we selected we'll continue down here. 48 00:03:27,510 --> 00:03:30,630 And then you will pick a region to host your database in. 49 00:03:30,930 --> 00:03:35,850 So once you are using or when you are using the free copy like we are you either get to pick from the 50 00:03:35,850 --> 00:03:38,790 EU or from US East. 51 00:03:38,850 --> 00:03:41,270 So just pick whichever one is closer to you. 52 00:03:41,370 --> 00:03:44,480 If you are off continent somewhere that is totally fine. 53 00:03:44,490 --> 00:03:45,570 Just pick either one. 54 00:03:45,570 --> 00:03:47,570 It doesn't really make a big difference. 55 00:03:47,700 --> 00:03:51,350 So going to pick us East because I'm in the US. 56 00:03:51,540 --> 00:03:52,560 Click Continue. 57 00:03:52,560 --> 00:03:55,350 And then finally we need to enter a database name. 58 00:03:55,620 --> 00:04:03,630 So for us we're going to use a database name of email the dash DEP like so and then for the database 59 00:04:03,630 --> 00:04:07,220 version you can just leave it at whatever the default is. 60 00:04:07,290 --> 00:04:09,720 If you see a newer version here that's totally fine. 61 00:04:09,720 --> 00:04:11,880 Don't sweat it. 62 00:04:11,970 --> 00:04:13,330 So we'll continue. 63 00:04:13,380 --> 00:04:16,180 We'll submit the order and that is pretty much it. 64 00:04:16,500 --> 00:04:21,240 So pretty painless especially compared to hosting your own local copy. 65 00:04:21,240 --> 00:04:22,050 Believe me. 66 00:04:22,530 --> 00:04:27,240 Now unfortunately there is one last step that we have to go through but it is still pretty painless. 67 00:04:27,270 --> 00:04:28,750 So let's do it right now. 68 00:04:29,250 --> 00:04:34,170 You should see a new database pop up on your Mongo DB deployment list right here. 69 00:04:34,170 --> 00:04:35,310 And so here's mine. 70 00:04:35,370 --> 00:04:37,210 Email the dash dev. 71 00:04:37,540 --> 00:04:38,810 So I'm going to expand it. 72 00:04:39,860 --> 00:04:45,770 And I get taken to the dashboard for this database now immediately you'll see that we do not have any 73 00:04:45,770 --> 00:04:46,880 collections. 74 00:04:46,880 --> 00:04:49,430 So we have no records whatsoever. 75 00:04:49,430 --> 00:04:52,150 We will also see two quick notifications on here. 76 00:04:52,370 --> 00:04:55,800 The first one is hey this is not really suitable for production. 77 00:04:55,820 --> 00:04:56,780 Ok whatever. 78 00:04:56,960 --> 00:04:59,650 And then the second one is a little bit more relevant to us. 79 00:04:59,660 --> 00:05:05,040 It says a database user is required to connect to this database. 80 00:05:05,150 --> 00:05:10,220 So this is something that we have to do to use this database at all. 81 00:05:10,220 --> 00:05:18,140 Now to be really clear I'm going to spell this out and make sure it is crystal clear in our application. 82 00:05:18,140 --> 00:05:22,910 We're going to have users write people who like to sign into our application. 83 00:05:22,910 --> 00:05:26,840 Those users will be stored in a user's collection. 84 00:05:26,840 --> 00:05:31,700 So we're going to have a collection called users and it will have all the different people who sign 85 00:05:31,700 --> 00:05:33,230 up for application. 86 00:05:33,800 --> 00:05:41,510 A user that this notice right here is talking about is a data base user it is an account that is used 87 00:05:41,720 --> 00:05:44,360 to access the Mongo DVH database. 88 00:05:44,360 --> 00:05:47,980 So these are two completely separate users. 89 00:05:48,020 --> 00:05:52,860 One is a user inside of our application who is like going through the process. 90 00:05:52,880 --> 00:06:00,380 The other is the other is like an administrative account or a service account that we are using to access 91 00:06:00,440 --> 00:06:02,110 and modify this database. 92 00:06:02,120 --> 00:06:04,050 So two separate sets of users. 93 00:06:04,370 --> 00:06:09,930 And I'm sorry if I seem really extreme as I say this but many people in the past have been very confused. 94 00:06:09,950 --> 00:06:12,680 So I just want to spell it out and make sure it's crystal clear. 95 00:06:13,210 --> 00:06:13,480 OK. 96 00:06:13,520 --> 00:06:14,480 Let's do it. 97 00:06:14,480 --> 00:06:16,100 We're going to find the users button. 98 00:06:16,220 --> 00:06:17,030 Here it is right here. 99 00:06:17,060 --> 00:06:21,270 Click it and then I'll find the button over here that says ad database user. 100 00:06:21,740 --> 00:06:26,810 So we are now prompted to enter in a database username and a database password. 101 00:06:26,810 --> 00:06:31,990 Now these are entries that you will probably want to use something reasonably secure. 102 00:06:32,000 --> 00:06:35,630 Do remember that this is a development are kind of like a test database. 103 00:06:35,630 --> 00:06:38,990 It's not going to host our production data at the end of the day. 104 00:06:39,090 --> 00:06:41,560 So you know do something reasonably secure. 105 00:06:41,660 --> 00:06:43,770 But for me I'm going to keep it easy. 106 00:06:43,790 --> 00:06:49,670 I was going to do this username of username you know actually let's do something a little bit more clear 107 00:06:49,670 --> 00:06:50,050 than that. 108 00:06:50,060 --> 00:06:52,550 Let's do this Steven. 109 00:06:52,670 --> 00:07:00,470 Why not my name and then I'm going to use a password of just password and keep it really easy and really 110 00:07:00,490 --> 00:07:04,870 straightforward and then make sure that Read-Only is not checked. 111 00:07:04,880 --> 00:07:07,580 We do not want this to be a read only account. 112 00:07:07,730 --> 00:07:12,450 So finally we'll click Create at the bottom and that's pretty much it. 113 00:07:12,470 --> 00:07:18,050 So we should now see on this user's tab one database user. 114 00:07:18,140 --> 00:07:19,940 This is the name of the account. 115 00:07:19,940 --> 00:07:23,940 It is not a read only account so it should say false right there. 116 00:07:24,020 --> 00:07:30,890 And we now have a database account or a database user that can be used to access and modify our Mongo 117 00:07:30,890 --> 00:07:32,640 divi instance. 118 00:07:32,660 --> 00:07:33,020 OK. 119 00:07:33,050 --> 00:07:36,700 So that really truly is it for our IN lab setup. 120 00:07:36,740 --> 00:07:37,890 We're now going to take a break. 121 00:07:37,940 --> 00:07:43,910 When we come back we're going to install mongoose on our express API and then we're going to instruct 122 00:07:43,910 --> 00:07:50,000 mongoose how to connect to this particular copy of Mongo D-B that we just set up. 123 00:07:50,360 --> 00:07:52,130 So all Catcher in the next section.