All right.
Up next, let's start working on the user model.
So at the moment, we have jobs, but in our application.
The jobs are going to belong to a user so each user can create the job, delete the job and rest of
the stuff.
Now, before we start setting up the user model, a very important thing, let's clean out everything
from database because eventually we will die both of these models together and you definitely will avoid
some unnecessary bugs if you start from the scratch.
So let's navigate to our cloud, the Atlas one, and simply click on jobs.
Don't worry, we will set them back up just for now.
We want to remove it since again, at the moment our jobs don't belong to a specific user, which eventually
of course is going to be the case.
Next, we want to create our user model.
So same deal.
We navigate to models, then we go with new file.
I'm going to call this user model.
So let's start with Mongoose from Mongoose.
Okay, That's awesome.
Then let's create the schema.
I'm going to go with user schema that is equal to my new mongoose.
Your mongoose dot and then schema.
Let's set up our object and we'll have a few properties.
We'll start here with string, then we'll have the email, also string then.
And for some reason this wasn't correct, then we're going to go with password, which also will be
a string.
Then we have a last name.
This is going to be technically an object because I'll set up some defaults, so I'm going to go here
with type string and then default.
It's going to be equal to lastname.
Let's save this.
Then we also have location.
Also an object type equals to a string.
Then default.
I'll set it equal to my city.
You can also go Earth or Florida.
That's always a good option.
And then lastly, we'll have a role.
So in this application.
Users are going to have roles now, totally.
Honestly, only one user is going to be admin unless you choose to set it up differently.
But as far as our code, there's only going to be one admin user.
And of course admin users have more privileges.
In our case, admin user is going to have access to the total amount of users and jobs in the application.
But of course sky's the limit.
Now as far as the role, yes, it's going to be a string, but we'll set it up here as enum.
And as far as the options we're going to go with user.
An admin.
Then we're also going to set up default and we're going to go with user.
Now one last thing we want to do in this video.
Is to export default.
And then remember, we're looking for Mongoose dot.
Then model.
Let's come up with a name.
In my case, it's going to be user and we want to pass in the user schema.
And with this in place, we are ready to move on to the next step.