WEBVTT

00:00.640 --> 00:04.560
So let's connect to our MongoDB instance in our index TS

00:05.060 --> 00:08.440
file. In order to do that we can go to the listen command making a

00:08.940 --> 00:12.720
Sync and the ConnectDB

00:13.220 --> 00:15.520
would be an actually a separate application command.

00:16.800 --> 00:20.200
So let's use GitHub Copilot to actually create this default configuration

00:20.700 --> 00:23.840
for us and then we will see what it will propose.

00:23.920 --> 00:27.470
Okay, so it's created the default function, then it

00:27.970 --> 00:31.550
also connected the MongoDB and then it's exported this function, which is

00:32.050 --> 00:34.590
exactly what we need. So we can accept this one. We will need to make

00:35.090 --> 00:38.030
a few changes because some of the parameters are a little bit outdated. So for

00:38.530 --> 00:42.030
example, you do not need to use the new URL password identified

00:42.530 --> 00:46.950
topology, at least in this case. Then you would need to change the

00:47.430 --> 00:50.870
MongoDB root, the MongoDB URL,

00:51.350 --> 00:54.750
the MongoDB URL to root

00:55.250 --> 00:59.120
because that's our user and password. And then you will need to add the

00:59.620 --> 01:03.000
port in order to connect it. And then we also know that our

01:03.500 --> 01:07.160
database called admin and then what

01:07.660 --> 01:11.320
we need to add extra is

01:11.820 --> 01:15.320
to fail the process when the mongodb connection is failed

01:15.820 --> 01:19.120
because we do not want to continue if MongoDB is not connected.

01:19.360 --> 01:23.380
So let's see, we would need to import this function from DB

01:23.880 --> 01:27.220
config and then let's try to run it and see how it is going on.

01:27.780 --> 01:31.340
So we will run start command and

01:31.840 --> 01:32.980
now we can see that we are connected to Mongo.
