WEBVTT

00:03.760 --> 00:05.260
Hey, did everyone had their share?

00:05.260 --> 00:07.720
And this video should be longer at your side?

00:07.720 --> 00:09.190
Not my side.

00:09.190 --> 00:14.500
And this video is, moreover, about to give you some inspiration that, hey, once you are done with

00:14.500 --> 00:18.970
this course, you should really next up, spend probably entire week or maybe month.

00:18.970 --> 00:24.820
It would be not wrong to spend time on Mongoose and MongoDB over the time in this course.

00:24.820 --> 00:28.900
Also, I will walk you through with a couple of instances that only you can understand if you are reading

00:28.900 --> 00:33.790
the documentation thoroughly and asking some questions, a meaningful question that you want to find

00:33.790 --> 00:34.900
answer on your own.

00:34.900 --> 00:36.610
Let me show you some example of that.

00:36.820 --> 00:41.800
Now, in the previous of the section, we remember, if we created a couple of kind of authentication

00:41.800 --> 00:44.950
process, we stored some of the users in the database as well.

00:45.190 --> 00:50.290
Some of you might haven't got that question, but I would still like to walk you through with that question.

00:50.290 --> 00:51.820
So let me first open this up.

00:51.820 --> 00:58.540
So I'm going to go ahead and open up our AE back end and we created all of this into this AE auth system.

00:58.540 --> 01:04.030
So let me go ahead and open up the VS code and just drag and drop this auth system up here because I

01:04.030 --> 01:08.140
wanted to show you something really, really important and we have models in this section only.

01:08.350 --> 01:14.380
So in case you noticed up here, we did something deliberately wrong here, which is not supposed to

01:14.380 --> 01:17.170
happen, but I deliberately did it just to make this video.

01:17.170 --> 01:22.690
So notice here, this is a very small schema of user schema, but we deliberately wrote the Mongoose

01:22.690 --> 01:24.130
dot model as user.

01:24.130 --> 01:26.020
Now this is usually not the case.

01:26.020 --> 01:31.600
How you find it, you go ahead and usually find that that this u is written as uppercase u.

01:31.600 --> 01:35.950
This is how the Carmelita is being written, but via uppercase y lowercase.

01:35.950 --> 01:39.760
Why does it matter and what's going to happen now?

01:39.760 --> 01:45.610
Not only that, if I go ahead and open up my MongoDB visualizer, let me just go ahead and open that

01:45.610 --> 01:45.970
up.

01:47.820 --> 01:48.150
Okay.

01:48.150 --> 01:49.410
So finally it is up and running.

01:49.410 --> 01:54.180
Let me go ahead and connect to my local database and we call this one as ae auth.

01:54.180 --> 01:57.630
If I go up here notice very carefully it says users.

01:57.630 --> 02:01.500
So I didn't ask it to create users, I just asked them to create user.

02:01.500 --> 02:06.870
And this is exactly I have mentioned up here in here that, hey, just create a schema for user, not

02:06.870 --> 02:07.440
users.

02:07.440 --> 02:07.950
So what?

02:07.950 --> 02:09.480
Why does it happen now?

02:09.480 --> 02:14.760
This is all because you should be reading mode with the mongoose and spend some more time in the documentation.

02:14.760 --> 02:18.930
So promise that after completing this course you will be spending more time with the mongoose.

02:18.930 --> 02:21.090
And let me show you a reason why does it happen?

02:21.090 --> 02:25.590
So if I go ahead and open up this mongoose documentation and we are going to be studying the models

02:25.590 --> 02:27.240
for that, how to create the model.

02:27.270 --> 02:31.340
They give you a very basic example here that, hey, you can go ahead and use this schema which has

02:31.350 --> 02:33.780
simple name, string and size of the tank.

02:33.780 --> 02:38.940
And then we go ahead and say Mongoose model the tank and the schema that we have provided.

02:38.940 --> 02:41.220
So in the tank they write this T as capital.

02:41.250 --> 02:46.290
Now whether you write this T is capital or lowercase doesn't matter because the next line is very important.

02:46.320 --> 02:49.740
The first argument is the singular name of the model of the collection.

02:49.740 --> 02:52.020
So singular name here can be tank with uppercase.

02:52.020 --> 02:53.640
Lowercase doesn't really matter.

02:53.670 --> 02:58.620
Mongoose automatically looks for plural lowercase version of your model.

02:58.620 --> 03:02.790
So Mongoose, no matter what you write, you write a tank or you write bus.

03:02.790 --> 03:08.400
Mongoose is automatically going to look for some of the models and will convert into pure and we'll

03:08.400 --> 03:11.640
bring it in all lowercase that is finally going to happen.

03:11.640 --> 03:14.700
So doesn't matter if you put it a lowercase or uppercase how you do that.

03:14.700 --> 03:18.000
This is exactly how the result and the outcome is going to come in.

03:18.000 --> 03:23.880
Now, I have seen in some of the cases the plural version designed by the mongo is not really the actual

03:23.880 --> 03:24.990
correct version of it.

03:24.990 --> 03:26.130
But hey, we are programmers.

03:26.130 --> 03:31.380
We are not that much panicked about how the English actually works in moving further notice here.

03:31.380 --> 03:36.270
Another line says the model function makes a copy of schema in case you get that nice, but otherwise

03:36.420 --> 03:41.640
make sure that you add everything that you want of the schema, including hooks before calling the model.

03:41.640 --> 03:47.640
So before we actually go ahead and run this mongoose model and all of that, in case you have any functions

03:47.640 --> 03:53.100
which we will have in the next upcoming section, then make sure before calling this mongoose or model,

03:53.100 --> 03:55.530
make sure you all use that pre function and post.

03:55.530 --> 03:58.410
Remember we talked about some of the pre and post hooks and all of that.

03:58.410 --> 04:03.480
You want to write them all before I have seen so many times students coming in that hey, we have written

04:03.480 --> 04:05.520
these functions, but they are not executing.

04:05.520 --> 04:10.680
And I, I just mentioned this line, hey, did you read this this before using this mongoose dot model,

04:10.680 --> 04:12.240
you need to write them just above it.

04:12.240 --> 04:13.290
And that was it.

04:13.290 --> 04:17.700
So again, I'm telling you this because reading the documentation is one of the most important part.

04:17.700 --> 04:20.130
It is also boring, I'll give you on that.

04:20.130 --> 04:25.500
But with the course which is designed, focused all around the documentation, you actually explore

04:25.500 --> 04:27.690
a bit of documentation alongside with me.

04:27.690 --> 04:30.090
This is at least I can do so again.

04:30.090 --> 04:32.670
Go ahead and enjoy some documentation in your free time.

04:32.670 --> 04:34.050
Just read a few of the lines.

04:34.050 --> 04:39.150
Maybe something interesting will pop up and in the next section or not section, the next video we are

04:39.150 --> 04:42.060
going to go ahead and read the documentation of Razorpay.

04:42.060 --> 04:47.850
We will finally create a new project and we will create a kind of a bare minimum basic for handling

04:47.850 --> 04:48.330
payments.

04:48.330 --> 04:49.500
Why are razorpay?
