WEBVTT

00:03.850 --> 00:05.380
Hey, did everyone share?

00:05.380 --> 00:09.160
And let's address our second and the final problem of this section.

00:09.160 --> 00:11.530
And you might be wondering, hey, this you told us three problems.

00:11.530 --> 00:12.840
The first one was hiding secret.

00:12.850 --> 00:16.810
The second one was scalability or breaking up the code itself.

00:16.810 --> 00:18.310
And the third one was database.

00:18.800 --> 00:23.230
We don't need any packages for handling the scalability or the breaking of the files.

00:23.230 --> 00:24.280
We can do it on our own.

00:24.280 --> 00:25.870
So that's why it's not a big issue.

00:25.900 --> 00:27.400
Hiding secret part is all done.

00:27.400 --> 00:32.200
Now let's go ahead and talk about the database now for this entirety of the course, we are going to

00:32.200 --> 00:34.260
choose the MongoDB as our database.

00:34.270 --> 00:37.210
Now, here comes the big question that why MongoDB?

00:37.210 --> 00:38.380
Why not MySQL?

00:38.380 --> 00:42.640
Why not PostgreSQL or why not to choose some of the graph database or something else.

00:42.640 --> 00:47.770
Now, this is where a lot of expertise come in and that is definitely out of the scope of this course.

00:47.770 --> 00:50.890
But still, I'll give you some of the pointers that you can keep an eye on.

00:50.920 --> 00:56.500
Now, recently, if you read some of the articles from the big tech giants recently what I studied from

00:56.500 --> 01:01.420
the zero the which is India is one of the leading firm of or the brokerage firm.

01:01.420 --> 01:07.510
So they wrote a very clearly in their article by their CTO that you can make an application as good

01:07.510 --> 01:08.260
as possible.

01:08.260 --> 01:12.550
But sometimes and most of the time the bottleneck actually comes from the database itself.

01:12.550 --> 01:15.970
It's not like my SQL is bad or MongoDB is bad.

01:16.000 --> 01:20.710
They both have their use cases and what you really want to do, what's the goal of your application?

01:20.710 --> 01:26.560
So bringing out the fact that which one is best for application, that's where the expertise of the

01:26.560 --> 01:30.730
experts or people who have worked years on, years on industry that comes in.

01:30.730 --> 01:36.460
And that's why I get hired and so many companies to to make the consultancy about which is best for

01:36.460 --> 01:40.720
their what the infrastructure infrastructure should look like, what tools to choose, what not to choose.

01:40.720 --> 01:45.400
So definitely this is a little bit out of scope and that can we can have a great debate probably on

01:45.400 --> 01:50.080
the Saturday Live or something on my YouTube channel right now, we have decided that we are going to

01:50.080 --> 01:50.950
go with MongoDB.

01:50.950 --> 01:54.970
This is one of the most industries in demand database right now.

01:54.970 --> 01:59.380
But once you understand the core foundation of how to work with that, working in other databases is

01:59.380 --> 02:02.950
almost equally kind of same process.

02:02.950 --> 02:06.880
Yes, there are some expertise you have to gain there, but it's good there.

02:07.060 --> 02:12.760
Now comes up the big question and a very, very big question, which is we are going to choose an ARM

02:12.760 --> 02:16.750
or an ODM, the kind of a same they do the same work in the relational world.

02:16.750 --> 02:18.070
We call them as Aurum.

02:18.070 --> 02:23.680
In the world of databases which are similar to MongoDB, no sequels we call them as ODM.

02:23.710 --> 02:29.200
Aurum stands for Object Relational Mapper in the ODM, we call it as object data mapper.

02:29.200 --> 02:30.550
The goal is really simple.

02:30.550 --> 02:34.090
They help us to perform some operations with the database.

02:34.090 --> 02:39.160
It can be all the correct operation, like create some values inside the database, retrieve some value,

02:39.160 --> 02:41.170
delete them, update them and all of that.

02:41.260 --> 02:44.680
So the bigger question is why do we need an OAM?

02:44.680 --> 02:46.900
Can we work directly with the MongoDB?

02:47.350 --> 02:49.270
Why we are injecting something in between?

02:49.270 --> 02:51.160
So let me just walk you through with that.

02:51.160 --> 02:56.500
If I go into the documentation of MongoDB itself, this is the home page website of the MongoDB.

02:56.530 --> 02:58.750
You can see there is a connect your application.

02:58.750 --> 03:00.820
You can just go ahead and choose your driver.

03:00.820 --> 03:04.900
So MongoDB yes, they provide you direct drivers that you can inject.

03:04.900 --> 03:09.340
So I can just click up here and I can say that, hey, I want to use the Node.js drivers.

03:09.340 --> 03:14.350
I can go ahead and select my application and they say that this is how you can do it and this is all

03:14.350 --> 03:15.490
what we are having now.

03:15.490 --> 03:18.100
Let's go ahead and go for a quick usage example.

03:18.100 --> 03:21.040
Of course, there are examples for installation and everything.

03:21.040 --> 03:21.850
We can do that.

03:21.850 --> 03:26.140
But if you go up here that this is that, yeah, you can actually go ahead and use this.

03:26.140 --> 03:29.830
Let me go back here and show you some of the more drivers up here.

03:30.040 --> 03:32.500
So let's go ahead and say connect to MongoDB.

03:32.500 --> 03:33.850
I want to connect it through it.

03:33.850 --> 03:36.130
So these are the URL that will be given to you.

03:36.130 --> 03:38.440
It can be local install or somewhere else.

03:38.920 --> 03:43.930
And now all we have to do is say, hey, we are going to require the MongoDB, of course after installation

03:43.930 --> 03:46.160
and then we can simply provide the URL.

03:46.160 --> 03:51.730
I connect with that and connect with the MongoDB database instance itself and everything is given and

03:51.730 --> 03:52.330
mentioned.

03:52.450 --> 03:57.970
So if we can use the MongoDB drivers directly, why do we need to inject an item?

03:57.970 --> 04:03.700
And a lot of time people who are pro backend developers make this argument that ORM can actually slow

04:03.700 --> 04:04.390
your application.

04:04.390 --> 04:07.900
You should directly talk to the database or use the driver itself.

04:07.930 --> 04:13.510
Now I do some extent I agree with them, but onto a massive, massive application and I'm not talking

04:13.510 --> 04:16.540
about 500,000 users or a million users.

04:16.540 --> 04:22.510
I'm talking about 5 million users or 10 million users or some some scale of that request that, yes,

04:22.510 --> 04:27.100
you want something where you can actually remove the bottleneck of the database itself.

04:27.100 --> 04:30.250
Now the bigger question is should you be using an ottoman ODM?

04:30.250 --> 04:32.770
Yes, my recommendation is absolutely 100%.

04:32.770 --> 04:33.940
You should be using it.

04:33.970 --> 04:37.660
I always give an example of can I run without the running shoes?

04:37.660 --> 04:38.650
Yes, you can.

04:39.100 --> 04:40.240
Is it going to help you?

04:40.270 --> 04:40.630
Yes.

04:40.630 --> 04:41.710
Running shoes helps you.

04:41.740 --> 04:43.330
Same goes for basketball.

04:43.600 --> 04:45.730
Can I play basketball without having good shoes?

04:45.730 --> 04:46.510
Yes, you can.

04:46.510 --> 04:51.880
You will still be able to shoot all the three pointers, but in case you have good shoes, it actually

04:51.880 --> 04:54.100
helps you a little bit in the initial days.

04:54.100 --> 04:56.770
Same goes for the Aurum and ODM that yes.

04:56.770 --> 04:58.390
In the initial days they help you a lot.

04:58.390 --> 05:01.540
In fact, you'll be able to write your code much faster, easier and in.

05:01.820 --> 05:07.240
Near Manor and the tons of tons of people use that is the industry standard coming back.

05:07.240 --> 05:09.730
What kind of OEM or ODM we are going to choose?

05:09.730 --> 05:13.930
We are going to choose Mongoose, which is one of the industry standard and everybody uses that.

05:13.960 --> 05:15.050
Is it the only one?

05:15.070 --> 05:15.910
No, not at all.

05:15.910 --> 05:21.730
If you'll search for IRM or ODM for MongoDB, you'll find so many of them and every single month new

05:21.730 --> 05:22.840
ones are popping around.

05:22.840 --> 05:28.090
But still, this is the industry leader and it is probably going to stay there for a long while.

05:28.090 --> 05:29.920
So we're going to study more about that.

05:29.920 --> 05:34.480
And in the next video we are going to see that how we can take advantage of the mongoose, just like

05:34.480 --> 05:38.290
we have studied in depth about the express we are going to do same for Mongoose.

05:38.290 --> 05:43.000
So we are going to learn how we can use validation, casting, what even that is how we can write the

05:43.240 --> 05:47.260
business logics and boilerplate and all of that, and how we can do all of this.

05:47.260 --> 05:52.090
So I think that gives you a pretty clear understanding of what we are doing, why we are doing, and

05:52.090 --> 05:53.590
what's the reason behind that.

05:53.590 --> 05:54.880
So let's go ahead.

05:54.880 --> 05:57.430
And in the next video, let's talk about Mongoose.
