Hey, did everyone had their share?
And this video should be longer at your side?
Not my side.
And this video is, moreover, about to give you some inspiration that, hey, once you are done with
this course, you should really next up, spend probably entire week or maybe month.
It would be not wrong to spend time on Mongoose and MongoDB over the time in this course.
Also, I will walk you through with a couple of instances that only you can understand if you are reading
the documentation thoroughly and asking some questions, a meaningful question that you want to find
answer on your own.
Let me show you some example of that.
Now, in the previous of the section, we remember, if we created a couple of kind of authentication
process, we stored some of the users in the database as well.
Some of you might haven't got that question, but I would still like to walk you through with that question.
So let me first open this up.
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.
So let me go ahead and open up the VS code and just drag and drop this auth system up here because I
wanted to show you something really, really important and we have models in this section only.
So in case you noticed up here, we did something deliberately wrong here, which is not supposed to
happen, but I deliberately did it just to make this video.
So notice here, this is a very small schema of user schema, but we deliberately wrote the Mongoose
dot model as user.
Now this is usually not the case.
How you find it, you go ahead and usually find that that this u is written as uppercase u.
This is how the Carmelita is being written, but via uppercase y lowercase.
Why does it matter and what's going to happen now?
Not only that, if I go ahead and open up my MongoDB visualizer, let me just go ahead and open that
up.
Okay.
So finally it is up and running.
Let me go ahead and connect to my local database and we call this one as ae auth.
If I go up here notice very carefully it says users.
So I didn't ask it to create users, I just asked them to create user.
And this is exactly I have mentioned up here in here that, hey, just create a schema for user, not
users.
So what?
Why does it happen now?
This is all because you should be reading mode with the mongoose and spend some more time in the documentation.
So promise that after completing this course you will be spending more time with the mongoose.
And let me show you a reason why does it happen?
So if I go ahead and open up this mongoose documentation and we are going to be studying the models
for that, how to create the model.
They give you a very basic example here that, hey, you can go ahead and use this schema which has
simple name, string and size of the tank.
And then we go ahead and say Mongoose model the tank and the schema that we have provided.
So in the tank they write this T as capital.
Now whether you write this T is capital or lowercase doesn't matter because the next line is very important.
The first argument is the singular name of the model of the collection.
So singular name here can be tank with uppercase.
Lowercase doesn't really matter.
Mongoose automatically looks for plural lowercase version of your model.
So Mongoose, no matter what you write, you write a tank or you write bus.
Mongoose is automatically going to look for some of the models and will convert into pure and we'll
bring it in all lowercase that is finally going to happen.
So doesn't matter if you put it a lowercase or uppercase how you do that.
This is exactly how the result and the outcome is going to come in.
Now, I have seen in some of the cases the plural version designed by the mongo is not really the actual
correct version of it.
But hey, we are programmers.
We are not that much panicked about how the English actually works in moving further notice here.
Another line says the model function makes a copy of schema in case you get that nice, but otherwise
make sure that you add everything that you want of the schema, including hooks before calling the model.
So before we actually go ahead and run this mongoose model and all of that, in case you have any functions
which we will have in the next upcoming section, then make sure before calling this mongoose or model,
make sure you all use that pre function and post.
Remember we talked about some of the pre and post hooks and all of that.
You want to write them all before I have seen so many times students coming in that hey, we have written
these functions, but they are not executing.
And I, I just mentioned this line, hey, did you read this this before using this mongoose dot model,
you need to write them just above it.
And that was it.
So again, I'm telling you this because reading the documentation is one of the most important part.
It is also boring, I'll give you on that.
But with the course which is designed, focused all around the documentation, you actually explore
a bit of documentation alongside with me.
This is at least I can do so again.
Go ahead and enjoy some documentation in your free time.
Just read a few of the lines.
Maybe something interesting will pop up and in the next section or not section, the next video we are
going to go ahead and read the documentation of Razorpay.
We will finally create a new project and we will create a kind of a bare minimum basic for handling
payments.
Why are razorpay?