1
00:00:01,290 --> 00:00:10,170
In this video we are going to create connection string for MongoDB to be able to interact with the MongoDB

2
00:00:10,170 --> 00:00:14,220
database using our express application.

3
00:00:14,700 --> 00:00:19,590
So the first step is that if you don't have an account, click on try free.

4
00:00:19,590 --> 00:00:27,720
But if you have one click on sign in and I'm going to click on sign in and here I'm going to look in

5
00:00:27,750 --> 00:00:31,410
using my preferred login details, I'll start.

6
00:00:33,370 --> 00:00:34,030
All right.

7
00:00:34,030 --> 00:00:39,880
The next step is that click on this icon to create a project for me.

8
00:00:39,880 --> 00:00:46,600
I have a couple of projects that I've created, so I'll scroll down and then I'll click on New Project.

9
00:00:47,690 --> 00:00:55,550
The name of this project, I'll call this one as full stack block version three, and I'll click on

10
00:00:55,550 --> 00:00:56,330
next.

11
00:00:57,440 --> 00:01:00,350
Next is click on Create project.

12
00:01:01,360 --> 00:01:09,970
Next step is click on build a database, and here select the free tier by clicking on create.

13
00:01:11,920 --> 00:01:18,460
And here you need to select your cloud provider, meaning a region that is close to you.

14
00:01:18,490 --> 00:01:22,540
So I will select the default and I'll scroll down.

15
00:01:22,540 --> 00:01:30,790
And for the cluster name, I would like to rename this one as full stack block version three as a name

16
00:01:30,790 --> 00:01:32,230
of my project.

17
00:01:32,590 --> 00:01:36,880
For this we can use any name, so I'll click on Create Cluster.

18
00:01:39,560 --> 00:01:42,880
Next step is I need to provide the user.

19
00:01:42,890 --> 00:01:46,610
So here I'll provide a novatek.

20
00:01:48,640 --> 00:01:49,780
For the password.

21
00:01:49,780 --> 00:01:55,300
I'm going to click on auto generate secured password going to be as that.

22
00:01:55,570 --> 00:02:02,710
So next step is that make sure you copy the password because you may need it in the application to be

23
00:02:02,710 --> 00:02:03,850
able to connect.

24
00:02:03,850 --> 00:02:05,740
So I'll click on Copy.

25
00:02:05,740 --> 00:02:08,770
And lastly, I'll click on Create User.

26
00:02:08,800 --> 00:02:14,740
So let me get back to the application and let me pass the password here as that.

27
00:02:14,740 --> 00:02:23,410
For the meantime, the next step is that we need to add the IP address, meaning which region that you

28
00:02:23,410 --> 00:02:26,050
want them to use your application.

29
00:02:26,080 --> 00:02:34,450
If you click on add my current IP address, meaning that only users within my region can have access

30
00:02:34,450 --> 00:02:35,920
to my application.

31
00:02:35,920 --> 00:02:41,380
But for this one, I want anybody on the internet to have access to the application.

32
00:02:41,380 --> 00:02:51,220
So I'm going to provide a universal IP address at 0.0.0.04 zeros and I will click on Add entry.

33
00:02:53,120 --> 00:03:01,610
The next step is that I'll click on finished and close and click on Go to databases and here we go.

34
00:03:01,700 --> 00:03:03,530
So let's have some patience.

35
00:03:03,530 --> 00:03:05,900
What it is building our cluster.

36
00:03:05,930 --> 00:03:07,390
So what is building?

37
00:03:07,400 --> 00:03:09,260
Let's get back to application.

38
00:03:09,260 --> 00:03:15,140
And in here we are going to create a file called Dot E and V.

39
00:03:15,350 --> 00:03:22,160
So at the root of the project, I'm going to create one file and this one going to be as dot E and V.

40
00:03:22,160 --> 00:03:25,130
So what is the E and V file?

41
00:03:25,160 --> 00:03:32,990
This file is going to contain the code that we don't want to expose to the outside world, meaning a

42
00:03:32,990 --> 00:03:36,650
code that is more private for our case.

43
00:03:36,680 --> 00:03:42,590
A code that is more private for now is our MongoDB connection string.

44
00:03:42,680 --> 00:03:49,940
So if we expose our database connection string, it means that if a user have access to that, that

45
00:03:49,940 --> 00:03:55,730
user can perform all the operation of which we are not even aware of.

46
00:03:55,730 --> 00:03:57,950
In that way, we need to secure that.

47
00:03:57,950 --> 00:04:02,390
So here I'm going to provide a name called Mongo.

48
00:04:02,390 --> 00:04:03,770
You are l.

49
00:04:04,730 --> 00:04:07,980
And it's equal to the name of our connection strength.

50
00:04:08,000 --> 00:04:14,200
So here it has financed through our click on Connect and we have couple of options.

51
00:04:14,210 --> 00:04:22,370
So in here we are going to use Connect your application and I'll click on this one and I'm good to go.

52
00:04:22,370 --> 00:04:24,470
Lastly, I'll click on Close.

53
00:04:24,470 --> 00:04:27,230
So back here, I'm going to paste that one.

54
00:04:27,230 --> 00:04:29,600
So let's look at the you are here.

55
00:04:29,600 --> 00:04:38,330
You can see that after first latch we have the user and this what I provided and we have a password

56
00:04:38,330 --> 00:04:43,100
placeholder and you are going to use the password that I copied.

57
00:04:43,100 --> 00:04:49,460
For me this is my password and for this one I will change it after this video.

58
00:04:49,460 --> 00:04:53,630
So make sure that you use the exact password of yours.

59
00:04:53,630 --> 00:04:59,960
So I'm going to remove this one and then paste that one here and you can see this one is the name of

60
00:04:59,960 --> 00:05:00,740
the project.

61
00:05:00,740 --> 00:05:07,610
And after four slash here we are going to add the custom database name.

62
00:05:07,610 --> 00:05:12,950
If you don't do that, MongoDB is going to use what is called test database.

63
00:05:12,950 --> 00:05:17,240
So for this I'm going to name this one as full stock block.

64
00:05:17,690 --> 00:05:25,310
Next step is that we need to use this file inside the connect because you may need the connection string

65
00:05:25,310 --> 00:05:28,790
here or better so we can copy this one.

66
00:05:28,790 --> 00:05:33,800
And inside a deep connection string here, I will move this one and paste that.

67
00:05:34,010 --> 00:05:35,090
So let's save it.

68
00:05:35,090 --> 00:05:41,690
And now let's check our terminal and you can see that we have what is called DB Connect successfully.

