WEBVTT

1
00:00.770 --> 00:02.540
Hi everyone!

2
00:02.570 --> 00:14.810
My cluster already created and in this video I will show you how to connect the NestJS with the MongoDB

3
00:15.080 --> 00:15.650
database.

4
00:17.150 --> 00:21.830
And now let's go to the techniques and go to the Mongo.

5
00:22.760 --> 00:31.730
And to be honest instead of showing. Instead of

6
00:31.760 --> 00:36.620
Remember this the code and show that to you.

7
00:37.100 --> 00:38.570
I will NOT do that.

8
00:39.410 --> 00:43.970
Okay, I will show you the documentation.

9
00:45.320 --> 00:54.020
Because in the real life, if you work with the real company, you might work with different frameworks

10
00:54.020 --> 00:59.870
and different languages and with different frameworks.

11
01:00.890 --> 01:05.060
It has a many way to connect the database.

12
01:05.210 --> 01:06.870
So for that reason.

13
01:06.900 --> 01:12.270
Never remember the code, instead of remember the documentation.

14
01:13.290 --> 01:19.830
Okay, understand the documentation and read the docs and copy paste into your project.

15
01:20.850 --> 01:26.070
So for that reason I will show you the documentation and copy that.

16
01:26.100 --> 01:26.730
Okay.

17
01:26.820 --> 01:31.800
I will not remember this code right here and show you.

18
01:34.380 --> 01:35.850
Now let me copy.

19
01:36.870 --> 01:39.420
Let me explain what's in the Mongo module.

20
01:40.230 --> 01:43.560
Actually the Mongo module right here already.

21
01:44.850 --> 01:45.510
Write

22
01:46.350 --> 01:51.300
It already write by the mongoose package.

23
01:51.330 --> 01:52.080
Right here.

24
01:52.170 --> 01:53.520
NestJS right here.

25
01:54.360 --> 01:54.720
Okay.

26
01:54.750 --> 01:56.400
And it's already export.

27
01:57.030 --> 02:09.060
So for that reason, we must import the Mongo module inside my module being the app module.ts

28
02:09.930 --> 02:17.970
The reason we import it inside the app.module.ts because I was many module.

29
02:18.930 --> 02:23.190
Many child module will accept inside the Mongo, right?

30
02:23.220 --> 02:27.390
For that reason we will import Mongo module right here.

31
02:28.200 --> 02:29.040
Let me copy that.

32
02:34.020 --> 02:35.280
Open the app module.

33
02:36.270 --> 02:39.870
Open the import and paste it right here.

34
02:41.850 --> 02:45.300
And I will copy the import statement okay.

35
02:46.020 --> 02:47.310
And paste that.

36
02:50.070 --> 03:01.860
And with the forRoot right here we must replace with my database in the previous video okay.

37
03:02.010 --> 03:11.340
Go to the database and go to the cluster and click the connect, okay.

38
03:11.340 --> 03:13.890
It will show the list of pop up right here.

39
03:14.190 --> 03:19.960
And click on the driver right here, and choose Node.js.

40
03:20.410 --> 03:25.060
And inside here we have a URL, right?

41
03:25.090 --> 03:25.990
Let me copy that.

42
03:26.380 --> 03:31.690
Copy that and replace with the Mongo URL right here.

43
03:32.980 --> 03:36.850
Now you can see, this is my Mongodb.

44
03:37.720 --> 03:46.810
And in the db underscore password we will remove that and replace with the password of the database.

45
03:50.110 --> 03:52.120
In the previous video right.

46
03:53.230 --> 03:56.140
We already set up the database account.

47
03:57.040 --> 04:02.230
And that is let me see, okay.

48
04:02.410 --> 04:06.850
Now let me run the application to see if it works or not.

49
04:07.150 --> 04:08.440
npm run start

50
04:11.050 --> 04:11.410
:dev

51
04:25.630 --> 04:27.010
And wait a bit.

52
04:37.420 --> 04:45.670
Now, right now, the authentication already failed, I think, because.

53
04:48.070 --> 04:50.380
Because I already was wrong.

54
04:50.380 --> 04:50.950
The password.

55
04:50.980 --> 04:53.200
I think like this.

56
04:56.080 --> 04:56.770
Let me see.

57
04:56.920 --> 04:57.280
Oh.

58
04:59.530 --> 05:01.120
I don't know why.

59
05:01.150 --> 05:04.570
Let me reset the password.

60
05:04.600 --> 05:08.080
Go to the security and database access.

61
05:10.420 --> 05:12.880
I will edit the password.

62
05:13.120 --> 05:14.020
Okay I will.

63
05:21.790 --> 05:23.200
Let me click on.

64
05:28.690 --> 05:29.440
Right here.

65
05:31.060 --> 05:37.270
I will click on update passwords and let me try to change that.

66
05:39.820 --> 05:43.750
And let me close project and run this again.

67
05:52.690 --> 05:54.040
Now you can see.

68
05:56.710 --> 06:01.300
For that reason the application already successfully right here.

69
06:01.360 --> 06:01.930
Okay.

70
06:02.890 --> 06:11.110
If you see the Nestjs application started, it means we already connected the database successfully.

71
06:11.800 --> 06:17.770
So make sure you remember the password okay.

72
06:17.800 --> 06:25.060
If not you can always go to the database access and click on this and press on the edit password over

73
06:25.060 --> 06:29.200
here to generate the new password.

74
06:30.640 --> 06:36.310
Okay I will close the video right now and see you in the next one.