1
00:00:00,390 --> 00:00:00,870
Beautiful.

2
00:00:01,230 --> 00:00:09,330
And once the basic set is up and running next, we want to connect to the database to our MongoDB Atlas

3
00:00:09,330 --> 00:00:09,690
account.

4
00:00:10,230 --> 00:00:13,740
And first, we want to get the connection string on my cache.

5
00:00:13,740 --> 00:00:19,200
I'm going to get it straight from Atlas, but remember, we have done quite a few project.

6
00:00:19,560 --> 00:00:26,040
So you definitely probably somewhere have the data and already with correct value when you want to set

7
00:00:26,040 --> 00:00:27,840
up data entry for this project.

8
00:00:28,320 --> 00:00:34,470
So remember, that needs to be in the root and you're going to come up with whatever variable name in

9
00:00:34,470 --> 00:00:34,800
this case.

10
00:00:34,800 --> 00:00:35,670
Just change it up.

11
00:00:35,670 --> 00:00:37,520
I think of what to go with Mongo.

12
00:00:37,530 --> 00:00:41,540
You are a member in the previous project with Went with Mongo, you are.

13
00:00:41,580 --> 00:00:44,880
I will set our connection string as a value.

14
00:00:45,330 --> 00:00:51,000
We will have to pass in the password as well as what is going to be a name for our database.

15
00:00:51,420 --> 00:00:59,990
We need to import Dot EMV package because remember, that package allows us to access environment variables.

16
00:01:00,090 --> 00:01:03,150
And if you remember, we need to also invoke it.

17
00:01:03,360 --> 00:01:10,470
So we need to go with dot config when we want to import or we function from the B folder.

18
00:01:11,130 --> 00:01:18,090
It's right over here where we're connecting and also cover why we don't need to use these deprecation

19
00:01:18,090 --> 00:01:20,760
warnings without it coming at the very, very end.

20
00:01:21,210 --> 00:01:23,910
And remember that we also need to restart the server.

21
00:01:24,300 --> 00:01:28,410
So every time we set up data entry, it's better to restart the server.

22
00:01:29,010 --> 00:01:33,210
So let me navigate to your MongoDB, so I'm looking for my Atlas one.

23
00:01:33,480 --> 00:01:40,440
More specifically, I want to connect to my application or grab the connection string that will navigate

24
00:01:40,440 --> 00:01:40,830
back.

25
00:01:41,670 --> 00:01:45,870
I want to go to the star, I want to create data entry.

26
00:01:45,960 --> 00:01:50,850
Like I said, in this case, I'm going to go with Mongo URL instead of your.

27
00:01:51,390 --> 00:01:58,080
Doesn't really matter, but I'm just going to go with a mongo underscore you URL, and then I'll just

28
00:01:58,080 --> 00:02:02,070
copy and paste and we want to set up that database.

29
00:02:02,460 --> 00:02:04,530
So here where we have my first database.

30
00:02:05,610 --> 00:02:10,949
As always, I'm going to go with the project name so 10 run high from e-commerce.

31
00:02:11,490 --> 00:02:16,890
I'm not going to add the API if you want, you can, but my guess I'm just going to go with an e-commerce.

32
00:02:17,340 --> 00:02:19,920
And then also, you want to set up your password.

33
00:02:20,340 --> 00:02:25,080
And once you do, save the file and navigate your app jazz.

34
00:02:25,410 --> 00:02:29,910
Once we're back in the app address, we want to import the connect function.

35
00:02:30,360 --> 00:02:31,830
So let's add here a comment.

36
00:02:31,950 --> 00:02:36,270
I'm just going to go with database and that's going to be equal to concert.

37
00:02:36,690 --> 00:02:38,190
Let's come up with some kind of name.

38
00:02:38,520 --> 00:02:40,380
We're going to go with Connect DB.

39
00:02:40,890 --> 00:02:44,870
Set it equal to require it is in the same folder.

40
00:02:44,880 --> 00:02:47,540
So we're just go with that and forward slash.

41
00:02:47,880 --> 00:02:51,320
Basically, it's not showing up or anything like that.

42
00:02:51,330 --> 00:02:52,600
We're just looking for DB.

43
00:02:53,100 --> 00:02:56,130
And then more specifically, you want to get the Connect one.

44
00:02:56,550 --> 00:03:01,440
It is a function and we want to invoke it before app that listen.

45
00:03:01,770 --> 00:03:04,610
And remember, it is the returning promise.

46
00:03:04,620 --> 00:03:13,050
So we want to go with a weight connect DB and then we want a passing process that the envy and the Mongo

47
00:03:13,470 --> 00:03:14,580
underscore URL.

48
00:03:15,000 --> 00:03:20,400
Now, before we do anything, we want to go above the express and what do we need to do?

49
00:03:20,790 --> 00:03:22,140
Well, we want to get the package.

50
00:03:22,530 --> 00:03:27,510
We dot the entry because we want to have access to those environmental variables, correct?

51
00:03:27,930 --> 00:03:30,180
Now the packages already installed.

52
00:03:30,450 --> 00:03:33,330
So if you take a look at the package JSON, we scroll up.

53
00:03:33,540 --> 00:03:34,410
Check it out.

54
00:03:34,410 --> 00:03:35,570
We have got it right.

55
00:03:36,060 --> 00:03:37,200
So let's navigate back.

56
00:03:37,710 --> 00:03:41,340
We're looking for the data entry, so let's just require it.

57
00:03:41,970 --> 00:03:43,410
Then let's go with the package name.

58
00:03:43,410 --> 00:03:48,510
Got the entry and then we want to go with config and we want to invoke it.

59
00:03:48,990 --> 00:03:50,150
Let's save it here.

60
00:03:50,220 --> 00:03:52,020
We want to restart the server.

61
00:03:52,920 --> 00:03:56,040
So it's where everything npm start.

62
00:03:56,520 --> 00:04:03,570
And then if everything is correct, right, we should see Server is listening on Port 5000 now.

63
00:04:03,570 --> 00:04:05,850
Lastly, we mentioned that for this project.

64
00:04:06,770 --> 00:04:14,570
We're going to use the Mongoose six, so as I was recording the project, as I already mentioned in

65
00:04:14,570 --> 00:04:15,390
the previous videos.

66
00:04:15,770 --> 00:04:17,810
Mongoose came out with version six.

67
00:04:18,360 --> 00:04:22,130
And the good news is that there's not much that we need to change.

68
00:04:22,400 --> 00:04:28,640
The only thing with Mongoose six is the fact that we don't need to add these deprecation warnings.

69
00:04:28,820 --> 00:04:34,610
In fact, if you will, if you add those deprecation warnings, then it's just going to spit some warnings

70
00:04:34,820 --> 00:04:35,600
in the council.

71
00:04:35,960 --> 00:04:43,490
So since I'm using Mongoose six, we don't need them and we simply can't get the function, invoke it

72
00:04:43,940 --> 00:04:45,080
and we're good to go.

73
00:04:45,620 --> 00:04:49,370
And once we have this in place, we can move on to the next step.

