1
00:00:00,330 --> 00:00:01,320
Not bad, not bad.

2
00:00:01,650 --> 00:00:03,690
Once our structure is in place.

3
00:00:04,019 --> 00:00:10,140
So essentially, once we have tested everything and we get back our damage strength now, it's finally

4
00:00:10,410 --> 00:00:16,320
set up our first model, which is going to be a user model, which we're going to use in order to register

5
00:00:16,620 --> 00:00:24,930
in order to log in and also in our application when we're setting up a new job and we're going to do

6
00:00:24,930 --> 00:00:28,740
that by creating models folder in the road.

7
00:00:29,130 --> 00:00:35,430
So again, we're talking about in here in the server, then we want to create user jobs and we want

8
00:00:35,430 --> 00:00:36,480
to set up these schema.

9
00:00:36,780 --> 00:00:40,260
So remember, we need to import mangoes and all that stuff.

10
00:00:40,650 --> 00:00:45,420
Now, as far as the properties, we're going to go with name, email, password, last name and location

11
00:00:45,900 --> 00:00:48,180
and for time being, you can set them up.

12
00:00:48,450 --> 00:00:54,660
All our strengths and I didn't add here export and set up to modern pickers.

13
00:00:54,660 --> 00:00:57,600
Again, at this point, it's somewhat self-explanatory.

14
00:00:57,960 --> 00:00:59,580
So let's start working on that.

15
00:00:59,580 --> 00:01:06,720
And then once I get to the properties, I'll show you what other things that I want to add here when

16
00:01:06,720 --> 00:01:07,710
we're setting them up.

17
00:01:08,130 --> 00:01:16,110
And in my case, I'm going to go to a sidebar here, say new folder, and I'm looking for models.

18
00:01:16,680 --> 00:01:20,790
And then inside of the folder, we want to create a new one.

19
00:01:21,580 --> 00:01:25,290
I mean, zoom in here, new file, and I'm going to go with user.

20
00:01:26,550 --> 00:01:34,140
Now we need to start by getting the mangoes out is coming from our package correct from and on my voice

21
00:01:34,140 --> 00:01:34,530
module.

22
00:01:35,740 --> 00:01:43,480
Now, once this is in place, then we want to create that schema, basically a structure for our user,

23
00:01:43,960 --> 00:01:45,550
and we're going to do that in the following way.

24
00:01:45,580 --> 00:01:53,650
We'll go with user schema that is equal to new mongoose and then schema.

25
00:01:53,860 --> 00:01:57,700
And once I have my schema, language is set up those properties one by one.

26
00:01:58,030 --> 00:01:59,560
So go here with a name.

27
00:01:59,570 --> 00:02:03,370
Like I said, type will be a strong one.

28
00:02:03,730 --> 00:02:05,560
Now what other properties we want to add here?

29
00:02:05,590 --> 00:02:08,169
Well, for sure, I want to set it up as required.

30
00:02:08,620 --> 00:02:12,490
So let's go here with required and I'm going to go with my custom message.

31
00:02:12,490 --> 00:02:15,220
So pass in the array central.

32
00:02:15,760 --> 00:02:22,750
And then we're going to go with please write the name, please provide and then name.

33
00:02:23,230 --> 00:02:24,190
Let's say this one.

34
00:02:24,520 --> 00:02:26,980
And I also want to add mid-length and maxlength.

35
00:02:27,400 --> 00:02:30,220
As far as mid-length, I think I'm going to go with three.

36
00:02:30,490 --> 00:02:34,120
And the maxlength will be equal to 20.

37
00:02:34,660 --> 00:02:39,780
And lastly, I also want to trim any extra space from the start or the end.

38
00:02:39,820 --> 00:02:41,380
So I'm going to go here with true.

39
00:02:41,920 --> 00:02:46,960
So once we have this one in place, we can pretty much copy and paste this one.

40
00:02:47,530 --> 00:02:50,140
I want to say four times.

41
00:02:50,770 --> 00:02:54,070
But let's just start with one and then we'll see what happens.

42
00:02:54,460 --> 00:02:58,090
So in here, I'm going to go with email of the type.

43
00:02:58,480 --> 00:02:59,650
There will be string.

44
00:03:00,130 --> 00:03:03,700
Now, as far as the required, yep, that's there will be the case.

45
00:03:03,700 --> 00:03:06,160
But in this case, we're going to be looking for emails.

46
00:03:06,160 --> 00:03:10,570
So say please provide email now mid-length and maxlength.

47
00:03:10,870 --> 00:03:15,940
I don't think I'm going to use of these ones and I'm also not going to it.

48
00:03:16,060 --> 00:03:20,500
But I do want to set it up as unique, though, so I'm going to go with unique, true.

49
00:03:21,010 --> 00:03:29,350
Just keep in mind that this is not technically a validator, but it will ensure the user can only sign

50
00:03:29,350 --> 00:03:36,010
up with an email that is not already in the years, but also show you how we can do that in the controller.

51
00:03:36,370 --> 00:03:37,570
So I'll show you two options.

52
00:03:37,810 --> 00:03:42,040
I'll show you how we can check that right away and controller if the user is trying to sign up with

53
00:03:42,040 --> 00:03:44,310
an email that is already in years past.

54
00:03:44,350 --> 00:03:49,780
Keep in mind that we also have this option in the Mongoose, but technically this is not a validator.

55
00:03:50,110 --> 00:03:58,740
It is just using the indexing to make sure that only unique emails are accepted online in the next video.

56
00:03:58,750 --> 00:04:05,530
I'll set up the validator because if you watch the Note Express project, you know that we were using

57
00:04:05,530 --> 00:04:06,040
the rejects.

58
00:04:06,280 --> 00:04:11,980
In this case, I'll show you package that nicely validates emails and many other things for us.

59
00:04:12,340 --> 00:04:16,140
So type string required true and also unique.

60
00:04:16,149 --> 00:04:19,500
True, then, when it comes to a password.

61
00:04:20,740 --> 00:04:22,300
Well, just come in first here.

62
00:04:22,720 --> 00:04:27,900
Let's say that the name will be password news, then type string required.

63
00:04:27,910 --> 00:04:28,420
True.

64
00:04:28,600 --> 00:04:34,420
So this one stays the same password and it's not going to be unique.

65
00:04:34,810 --> 00:04:42,700
But I do want to have a mid-length so same in length and not as equal to six than we have last name,

66
00:04:43,060 --> 00:04:48,070
which to tell you, honestly, we're not going to like use it in the application.

67
00:04:48,430 --> 00:04:54,710
It's just there to kind of give it a more real life feel to the application.

68
00:04:54,730 --> 00:04:55,150
That's it.

69
00:04:55,480 --> 00:05:00,820
Pretty much it's going to be in our profile last name and we're not going to ask it when we're signing

70
00:05:00,820 --> 00:05:01,000
up.

71
00:05:01,840 --> 00:05:05,560
So basically, when you sign up, there's going to be some kind of default value.

72
00:05:05,980 --> 00:05:08,980
And then if you want in the application, you can change it.

73
00:05:09,250 --> 00:05:12,040
So by default, it's going to be a last name.

74
00:05:12,280 --> 00:05:13,110
So let's try that.

75
00:05:13,110 --> 00:05:16,900
I want to bring I'm going to go with that name in this case.

76
00:05:16,900 --> 00:05:18,850
So let me copy this one.

77
00:05:19,750 --> 00:05:22,600
And then right after the password, we'll set this one up.

78
00:05:23,170 --> 00:05:25,240
We'll say a last name.

79
00:05:25,540 --> 00:05:26,950
It's going to be type strength.

80
00:05:26,980 --> 00:05:30,760
It's not going to be required and I will trim it.

81
00:05:31,240 --> 00:05:34,390
So let me move this one up and my maxlength.

82
00:05:34,540 --> 00:05:36,640
Yeah, I think it can stay with 20.

83
00:05:36,640 --> 00:05:44,090
But let's also add a default and let's say last name or Smith or whatever you want.

84
00:05:44,110 --> 00:05:49,720
So Mark, I said, I'm going to go with a last name like, so let's save that one and then last one

85
00:05:49,720 --> 00:05:55,270
is going to be location, which is again going to be interesting where we're not going to ask for it

86
00:05:55,600 --> 00:05:56,710
when we're registering.

87
00:05:57,130 --> 00:05:59,200
However, in the application.

88
00:06:00,220 --> 00:06:05,620
Notice there is this profile page where you can change that value, and then we'll use that location

89
00:06:05,920 --> 00:06:12,610
in order to find a job, because the assumption is that most jobs most likely you'll apply in your local

90
00:06:12,610 --> 00:06:12,940
area.

91
00:06:13,300 --> 00:06:14,230
So it kind of makes sense.

92
00:06:14,620 --> 00:06:16,060
This one was already filled out.

93
00:06:16,300 --> 00:06:22,360
And if you want to change this, basically if you're applying to some kind of job that is outside of

94
00:06:22,360 --> 00:06:25,270
your, then you can always edit that over here.

95
00:06:25,270 --> 00:06:30,370
Or once you move here, you can actually change the location altogether.

96
00:06:30,550 --> 00:06:32,920
Either way, it makes sense online.

97
00:06:33,010 --> 00:06:36,570
Let me grab this one last name, and we'll just remember.

98
00:06:37,030 --> 00:06:38,080
So say here.

99
00:06:38,450 --> 00:06:39,070
Location.

100
00:06:40,050 --> 00:06:46,530
And then we're going to go type, strength trim through maxlength, same toe and default will be my

101
00:06:46,530 --> 00:06:46,890
city.

102
00:06:47,070 --> 00:06:47,520
That's it.

103
00:06:47,850 --> 00:06:50,070
That's all we want to do for now.

104
00:06:50,610 --> 00:06:57,780
And then once we have all of this in place, then we can just go with export default or export default.

105
00:06:58,050 --> 00:07:01,200
And then remember, we want to set up the model, correct?

106
00:07:01,470 --> 00:07:06,930
So we have our scheme, we have the structure now to set up our model and the way we do that, we go

107
00:07:06,930 --> 00:07:08,400
with Mongo model.

108
00:07:08,790 --> 00:07:13,680
And then the first thing is the name sort of, my gosh, I'm going to go with user, which will create

109
00:07:13,680 --> 00:07:17,880
that user's collection and finally be online.

110
00:07:17,910 --> 00:07:19,860
We're going to go with user schema.

111
00:07:20,130 --> 00:07:25,800
And with this in place now, we can set up the validator for the email.

