Not bad, not bad.
Once our structure is in place.
So essentially, once we have tested everything and we get back our damage strength now, it's finally
set up our first model, which is going to be a user model, which we're going to use in order to register
in order to log in and also in our application when we're setting up a new job and we're going to do
that by creating models folder in the road.
So again, we're talking about in here in the server, then we want to create user jobs and we want
to set up these schema.
So remember, we need to import mangoes and all that stuff.
Now, as far as the properties, we're going to go with name, email, password, last name and location
and for time being, you can set them up.
All our strengths and I didn't add here export and set up to modern pickers.
Again, at this point, it's somewhat self-explanatory.
So let's start working on that.
And then once I get to the properties, I'll show you what other things that I want to add here when
we're setting them up.
And in my case, I'm going to go to a sidebar here, say new folder, and I'm looking for models.
And then inside of the folder, we want to create a new one.
I mean, zoom in here, new file, and I'm going to go with user.
Now we need to start by getting the mangoes out is coming from our package correct from and on my voice
module.
Now, once this is in place, then we want to create that schema, basically a structure for our user,
and we're going to do that in the following way.
We'll go with user schema that is equal to new mongoose and then schema.
And once I have my schema, language is set up those properties one by one.
So go here with a name.
Like I said, type will be a strong one.
Now what other properties we want to add here?
Well, for sure, I want to set it up as required.
So let's go here with required and I'm going to go with my custom message.
So pass in the array central.
And then we're going to go with please write the name, please provide and then name.
Let's say this one.
And I also want to add mid-length and maxlength.
As far as mid-length, I think I'm going to go with three.
And the maxlength will be equal to 20.
And lastly, I also want to trim any extra space from the start or the end.
So I'm going to go here with true.
So once we have this one in place, we can pretty much copy and paste this one.
I want to say four times.
But let's just start with one and then we'll see what happens.
So in here, I'm going to go with email of the type.
There will be string.
Now, as far as the required, yep, that's there will be the case.
But in this case, we're going to be looking for emails.
So say please provide email now mid-length and maxlength.
I don't think I'm going to use of these ones and I'm also not going to it.
But I do want to set it up as unique, though, so I'm going to go with unique, true.
Just keep in mind that this is not technically a validator, but it will ensure the user can only sign
up with an email that is not already in the years, but also show you how we can do that in the controller.
So I'll show you two options.
I'll show you how we can check that right away and controller if the user is trying to sign up with
an email that is already in years past.
Keep in mind that we also have this option in the Mongoose, but technically this is not a validator.
It is just using the indexing to make sure that only unique emails are accepted online in the next video.
I'll set up the validator because if you watch the Note Express project, you know that we were using
the rejects.
In this case, I'll show you package that nicely validates emails and many other things for us.
So type string required true and also unique.
True, then, when it comes to a password.
Well, just come in first here.
Let's say that the name will be password news, then type string required.
True.
So this one stays the same password and it's not going to be unique.
But I do want to have a mid-length so same in length and not as equal to six than we have last name,
which to tell you, honestly, we're not going to like use it in the application.
It's just there to kind of give it a more real life feel to the application.
That's it.
Pretty much it's going to be in our profile last name and we're not going to ask it when we're signing
up.
So basically, when you sign up, there's going to be some kind of default value.
And then if you want in the application, you can change it.
So by default, it's going to be a last name.
So let's try that.
I want to bring I'm going to go with that name in this case.
So let me copy this one.
And then right after the password, we'll set this one up.
We'll say a last name.
It's going to be type strength.
It's not going to be required and I will trim it.
So let me move this one up and my maxlength.
Yeah, I think it can stay with 20.
But let's also add a default and let's say last name or Smith or whatever you want.
So Mark, I said, I'm going to go with a last name like, so let's save that one and then last one
is going to be location, which is again going to be interesting where we're not going to ask for it
when we're registering.
However, in the application.
Notice there is this profile page where you can change that value, and then we'll use that location
in order to find a job, because the assumption is that most jobs most likely you'll apply in your local
area.
So it kind of makes sense.
This one was already filled out.
And if you want to change this, basically if you're applying to some kind of job that is outside of
your, then you can always edit that over here.
Or once you move here, you can actually change the location altogether.
Either way, it makes sense online.
Let me grab this one last name, and we'll just remember.
So say here.
Location.
And then we're going to go type, strength trim through maxlength, same toe and default will be my
city.
That's it.
That's all we want to do for now.
And then once we have all of this in place, then we can just go with export default or export default.
And then remember, we want to set up the model, correct?
So we have our scheme, we have the structure now to set up our model and the way we do that, we go
with Mongo model.
And then the first thing is the name sort of, my gosh, I'm going to go with user, which will create
that user's collection and finally be online.
We're going to go with user schema.
And with this in place now, we can set up the validator for the email.