In this video.
Let's get started with how we can model data after we have explained the concept.
As usual, I have created a sample express server and I will provide this set of files for you.
Or better still, you can start with your own x server.
So let's look at the folders and files in it.
Again, this section is all about express or how to work with Mongoose.
Because for this one too, we have covered in details.
I have one folder called models and inside I have two files post model and then the user model.
Let's look at the post model files.
You can see I have title here and then the content and down here I created my model.
After I compiled my schema and exported the post I start.
That is the first file and a second file is going to be the users for user registration and for the
user.
I have one field code full name and then the country and I have compiled the schema to form user and
have exported.
I start and the next folder are going to be the root to create and then register user.
I have first root called post root and inside the root I have the function to create the post and save
into database.
And this one too.
There is nothing new until this point, and next root is to fetch all posts.
And that is it.
The next root also for users for user registration.
And this is a function for registration.
And this function or this root is for fetching all users and that is it about that folder.
The next folder is called the Utils and inside I have one file called DB Connect and this is a function
to connect to MongoDB.
You can see that I just export the connection from this file and I can connect to Mongoose or MongoDB
using a function.
But I think this is the easiest way to go and how to connect to MongoDB too.
We have covered in details and on the server file.
I have required those files and this file is to connect to MongoDB and my express and I have required
those two routes and here is my middleware to pass incoming payload and then the route handles and my
server is listening on port 3000.
So that is it about the files and folders.
And we are going to use these tools called Compas to able to visualize our database and better so we
can use the voice code extension for MongoDB.
And here I can look through my database also.
All right, so these are the folders and tools we are going to use to work with data modeling.
Then this video.
Let's get started with the first concept that is working with how we can relate document together using
the embedded way.