WEBVTT 0 00:00.180 --> 00:07.410 Now that we've created our ToDo list up and we've learned all about how we can persist data using databases 1 00:07.530 --> 00:14.700 and more specifically using MongoDB a NoSQL database, then the next step is learning how we 2 00:14.700 --> 00:20.990 can actually deploy these apps which have a database associated with it out there onto the worldwide 3 00:21.000 --> 00:21.610 web. 4 00:22.300 --> 00:31.150 Currently, in order to access our website we go to localhost:3000 and that means that we're using our 5 00:31.150 --> 00:38.920 local computer as the server to serve up the information and data in our website. And that backed 6 00:38.920 --> 00:42.790 of course relies on Node.js. Now in the last module 7 00:42.790 --> 00:50.410 we also learned how to persist our data to save it to a database using MongoDB. 8 00:50.410 --> 00:59.770 Now the MongoDB database is also served up from our local computer and the URLs that we use to access be it 9 01:00.220 --> 01:05.880 our server or MongoDB all have the word localhost in it. 10 01:05.890 --> 01:07.800 So if you take a look up here, when 11 01:08.050 --> 01:14.950 we've been accessing app we've been using the hypertext transfer protocol. We've been going to a port 12 01:15.040 --> 01:22.780 3000 on the localhost and we needed to access our database, we've been accessing it at port 2701 13 01:22.780 --> 01:23.710 7 14 01:23.710 --> 01:30.610 also on our localhost. Now the part before the colon differ because here we're using the hypertext transfer 15 01:30.640 --> 01:31.500 protocol, 16 01:31.570 --> 01:37.850 so a set of rules that govern how we transfer data across the Internet to access web pages. 17 01:37.960 --> 01:45.430 But here we're using the MongoDB rules which determines how you can access data in a MongoDB database. 18 01:45.430 --> 01:51.890 But essentially everything is all hosted on the same laptop that we're using for development. 19 01:52.180 --> 01:58.000 And this is great for testing while you're developing your apps but currently nobody other than ourselves 20 01:58.030 --> 02:02.680 can actually access our website which kind of defeats the purpose of it being a website 21 02:02.670 --> 02:02.920 right? 22 02:02.950 --> 02:04.780 If it's just made for us. 23 02:05.140 --> 02:06.360 So what can we do? 24 02:06.520 --> 02:13.900 Well we know from previous lessons that we can use a data server that's online 24/7 and attached to 25 02:13.900 --> 02:20.070 the Internet backbone which will be able to host our Node.js server and be able to deliver our web 26 02:20.070 --> 02:23.430 site wherever it's requested across the Internet. 27 02:24.410 --> 02:30.680 And we've been using Heroku to do this which means that instead of using localhost:3000 we can use 28 02:30.770 --> 02:37.760 some sort of app name .herokuapp.com and anybody no matter where they live or how they're accessing 29 02:37.760 --> 02:43.730 the internet they can all access this web page through this address on the World Wide Web. 30 02:44.000 --> 02:51.260 Now that's all very well and good for an app that doesn't have a database, but our app does. In our 31 02:51.300 --> 02:59.060 case our todo list app actually needs to talk to the database to be able to create, read, update and 32 02:59.060 --> 03:01.940 delete data from our database. 33 03:02.300 --> 03:08.690 And if it's trying to do that from Heroku servers to the Mongo database that's hosted locally on our 34 03:08.690 --> 03:12.200 computer then that's not really going to work. 35 03:12.200 --> 03:16.960 So there's a few differences between a server and a workstation. 36 03:17.090 --> 03:24.500 For example the server pretty much has to be online 24/7 so that anybody who requests data from it can 37 03:24.500 --> 03:31.250 access it no matter what hour of the day. Also depending on what ISP or Internet service provider you're 38 03:31.250 --> 03:37.010 going with they have strict rules regarding whether you can set up a server using your home Internet 39 03:37.010 --> 03:37.600 plan. 40 03:37.820 --> 03:45.320 So what we have currently is a workstation and we need to move our database to a server for it to be 41 03:45.320 --> 03:48.920 served up 24/7 and across the internet. 42 03:49.400 --> 03:56.150 What we need to do is we need to set up another server which is capable of hosting MongoDB databases. 43 03:56.750 --> 04:03.380 And the service that we're going to use is MongoDB's own cloud service which is called Atlas. And 44 04:03.470 --> 04:11.000 this is going to allow us to have a web based address. MongoDB Atlas is going to host our database 45 04:11.360 --> 04:14.140 and serve up the data whenever it's needed. 46 04:14.150 --> 04:20.570 So that means that our Node.js app on Heroku will be able to make the necessary requests to our database 47 04:20.660 --> 04:28.010 that's hosted on the MongoDB Atlas cloud service and we'll be able to delete or update and be able 48 04:28.010 --> 04:35.510 to get data back from that database and that will all happen behind the scenes. Any users who needs to 49 04:35.510 --> 04:40.220 access your website will be going through your app.herokuapp.com 50 04:40.430 --> 04:45.900 and then your backed will liaise with MongoDB Atlas in order to talk to the database. 51 04:46.950 --> 04:53.330 So we no longer have any need for hosting our server or our database locally 52 04:53.490 --> 05:00.150 and that frees up our app and liberates it and puts it onto the Internet so that anybody can access 53 05:00.150 --> 05:00.480 it.