Hi everyone!
In this video I will show you how we can define the schema in the Netflix with the MongoDB.
Okay, so but before try to create a schema, firstly we need to create a subfolder structure okay some
define structure.
In here let's click on create and click on the users right here.
Well in the legend we can use the nest new command to generate the folder okay we call it legend.
We should follow the controller module and service right.
So for that reason in order to do that firstly I will click on the next.
Then right here we can generate the files by on schematics.
Let me show you how we can do that.
We can use the next generation and move the some schematics and move the name of the folder and you
can move the option.
Let me uh, 0111111.
Right here is symmetric.
We have so many symmetric.
Like for example I create a new class okay.
This is the alias or create controller decorator create filter okay.
Something like that in the file right here right now I will see you using the resource.
The reason because it will generate the new cross resource okay.
You can click on that to see what exactly does first generator TypeScript.
Right here we are using the.
Net generate resource right.
It will define for you the sun and Mars like that.
So let me show you how it works.
And inside here we have a sub option.
In this project we will disable the That's fine.
Right?
Right here.
This is the test file.
I will not test in this project for saving of time.
So I will use the option nodes.
Let me show you.
Hello.
I will use it against generous resource.
Right.
And I will name folders will be possible user.
Okay.
And I will put option middle spot.
Let us and let's enter.
Right here I will use the rest API.
And would you like to generate the cross.
Okay I will.
Yes.
Right here you can see if we overwrite it will create for you automatically the user folder.
Inside the user folder we have a controller module.
Okay.
And serve it.
And we also have some entity over here.
We will use our entity.
Okay.
This entity we will define the schema okay.
We will change the folder structure.
We will change the folder name from entities to schemas for consistency with our.
Modibodi okay.
All right.
And we also have a deal by default.
That is you already got a fundamental right.
Right.
Now let me define the user.
And then I will change those schemas inside here.
Let me change the user schema.
Dot txt and we will define some class.
Let's say how we can define us.
Firstly we will use the schema decorator okay let me do that.
And we need to import class right.
Sorry, we don't have.
See my column over here.
And in order to define, we will define some class, some property.
Okay.
And so we use the prop over here.
Okay.
Follow.
I will define a username.
Password.
Okay.
It later we will add more and more property over here.
But right now let's just test that and let's see how we can do this after we already define the schema.
Let me say let me scroll a little bit inside the import of the current module.
We will import the module module and register.
Okay.
Right now, let me copy everything over here.
Okay?
Never mind.
Try to memorize.
Let me show you how we can find out.
So you can click inside of those okay.
You can click inside of goes inside of models.
Let's click inside the model injection.
Model injection over here okay.
And right here your job is to scroll down a little bit to see this okay.
These are the user model.
Let me put the import statement.
And we import the module and lots of feature.
And right here let me import the user username okay.
And user.
Right here.
Let's see where this comes from.
It comes from.
Okay.
Make sure we will create us.
Okay.
I feel like we need to create a script.
Okay.
As not memorized as I will create a user document.
And we need to import the documentation and the user over here.
After we already got the document we will explore the schema over here.
So my user schema and the schema and you want to user okay.
So that is right here.
Let's put the user schema over here right.
Right now you might ask me what exactly about documentation.
What exactly about high res document.
Uh what is the schema for class?
Well, it doesn't really matter.
The only thing you need to know is how we can define a sub schema, and thus will be very enough for
most of job applications out there.
Okay, you don't need to try to understand what exactly about how the document or schema factory or
what exactly does it does really matter.
Okay, it's just about the rules.
And since we use the framework we need to follow the rules.
Okay.
The rules of the framework.
For that reason it is okay.
Let's ignore that.
You don't need to understand.
Okay.
And let's say we already start the application.
Let me go to the project and let me refresh.
Let me click inside the cluster.
Click on Browse collections.
And right here.
We already got the users.
Okay.
It comes from user schema.
It will auto generate for use this name.
Okay.
But right now we got the database name will be test.
I don't want that.
Right.
So for that reason.
Inside that module let's change the name of the project.
Let me show you.
In order to change the name of the project, let me show that.
Okay.
Not just how to rename the database.
You can show the submit.
That's not what we want right here.
I will just.
Project.
How to rename a database.
Okay.
Sorry.
In order to rename database after the localhost after the URL, we just need to put the name over here
between after this thing right here.
Let me boost again.
Okay.
Let me put the name will be also megabyte okay.
Like that.
And let's refresh the application and refresh the database also.
So here we already got this.
Also let me rock the test database.
Let's go and run the test.
So that's for the video I hope you understand.
I will see you in the next.