1
00:00:00,180 --> 00:00:00,600
Beautiful.

2
00:00:00,900 --> 00:00:06,660
And once we're done setting up day job functionality before we move on and start checking for permissions,

3
00:00:07,170 --> 00:00:14,790
I also want to show you the alternative approach because you might have some situations where that is

4
00:00:14,790 --> 00:00:16,980
actually the route that you want to take.

5
00:00:17,310 --> 00:00:20,880
Now, let me tell you right away that the video is optional.

6
00:00:21,240 --> 00:00:24,480
I'm adding this only to showcase multiple approaches.

7
00:00:24,480 --> 00:00:29,130
And like I just said, there might be a situation where you have a different set up.

8
00:00:30,050 --> 00:00:37,010
So not set up that we currently have the alternative approach is actually going to be the route that

9
00:00:37,010 --> 00:00:37,820
you'll need to take.

10
00:00:38,120 --> 00:00:40,370
And I also know that I will get these questions.

11
00:00:40,670 --> 00:00:45,650
In course, you and I so might as well set up the video and let's do it this way.

12
00:00:46,520 --> 00:00:52,310
Or first, we'll set up everything in the job and then I'll cover the differences.

13
00:00:52,820 --> 00:00:54,500
So here's what I want to do.

14
00:00:55,040 --> 00:00:58,700
Where we have the company in position for the time being, we'll leave it the way it is.

15
00:00:59,180 --> 00:01:00,830
We'll check for position and company.

16
00:01:00,950 --> 00:01:05,510
Pretty much the code stays here, same when we look for a job.

17
00:01:05,519 --> 00:01:07,790
If it doesn't exist, then we throw the error.

18
00:01:08,030 --> 00:01:10,100
And yes, eventually we'll check for permissions.

19
00:01:10,580 --> 00:01:16,340
But instead of find one and update, here's what I want to do since I have access to the job one by

20
00:01:16,340 --> 00:01:16,580
one.

21
00:01:16,640 --> 00:01:17,990
I'll update the properties.

22
00:01:18,320 --> 00:01:24,440
I'll go with position, the position and companies equal to company, and then we can go with a weight

23
00:01:24,770 --> 00:01:26,690
and job that's safe.

24
00:01:27,200 --> 00:01:32,870
So let's try it out, and then I'll cover why you would want to go with this approach.

25
00:01:33,200 --> 00:01:35,090
So let's go to jobs controller.

26
00:01:35,510 --> 00:01:39,050
First thing, yep, I have company in position, so that stays the same.

27
00:01:39,320 --> 00:01:41,990
Now I will revert back to update jump.

28
00:01:42,380 --> 00:01:43,670
So come on this one out.

29
00:01:44,660 --> 00:01:51,500
And then let's go with job, like I said, the first property is the position, and then that one will

30
00:01:51,500 --> 00:01:53,690
be equal to a position.

31
00:01:54,470 --> 00:01:59,090
Let's copy and paste one too many and then I'll set up two cursors.

32
00:01:59,780 --> 00:02:03,200
And in this case, we're going to go with a company one.

33
00:02:03,560 --> 00:02:04,550
Let's save it.

34
00:02:04,870 --> 00:02:09,770
And before we go any further, let's go and wait and then job and save.

35
00:02:10,160 --> 00:02:11,600
So let's save the job.

36
00:02:12,020 --> 00:02:16,930
And then in here, since I don't have updated Java anymore, I'm just going to go with job.

37
00:02:17,210 --> 00:02:21,980
But again, eventually I will revert back to this set up anyway.

38
00:02:22,240 --> 00:02:23,750
So let's go back to the postman.

39
00:02:24,230 --> 00:02:27,230
And let me check all the jobs senator over here.

40
00:02:27,650 --> 00:02:29,240
Looks like I have, Google added.

41
00:02:29,630 --> 00:02:32,810
That's the last one, and I just need to update.

42
00:02:33,080 --> 00:02:34,000
So I'm going to go.

43
00:02:34,010 --> 00:02:35,420
Not with Google added.

44
00:02:35,900 --> 00:02:41,150
This is going to go back to the Google one, and at the moment, I'll also remove the random one.

45
00:02:41,510 --> 00:02:42,210
Let's save it.

46
00:02:42,240 --> 00:02:43,220
Let's send it.

47
00:02:43,610 --> 00:02:46,310
And it looks like everything is working.

48
00:02:46,610 --> 00:02:51,470
So now let's talk about the differences with these two approaches.

49
00:02:51,770 --> 00:02:57,050
First, what we need to understand is that the reason why you would want to go with this one.

50
00:02:57,940 --> 00:03:05,950
Instead of find one and update is the simple fact that when it comes to find one and update, it does

51
00:03:05,950 --> 00:03:08,260
not trigger the hook.

52
00:03:08,980 --> 00:03:12,400
Now as you are looking at it, you're like, What are you talking about?

53
00:03:12,910 --> 00:03:14,320
We don't have the hook in here.

54
00:03:14,740 --> 00:03:15,490
And you're correct.

55
00:03:15,820 --> 00:03:19,870
But you might have the situation where you do have the hook in your model.

56
00:03:20,320 --> 00:03:24,580
And if that is the case, if you use this, find one and update.

57
00:03:25,090 --> 00:03:31,510
And let's say you have some kind of functionality that runs in that, OK, well, it's not going to

58
00:03:31,510 --> 00:03:32,770
trigger the hook altogether.

59
00:03:33,310 --> 00:03:38,940
And clearly discussed that when we talked about the hooks in the user one.

60
00:03:39,280 --> 00:03:41,810
So when we were dealing with the password.

61
00:03:41,830 --> 00:03:45,730
So if you need to jog your memory, please go back to those videos.

62
00:03:46,060 --> 00:03:50,500
So that's the first thing you need to remember that if you do have some kind of setup.

63
00:03:51,370 --> 00:03:57,850
Where you will be depending on those stocks in model venues, you'll have to go with this approach because

64
00:03:57,850 --> 00:03:59,950
this one will trigger the hook.

65
00:04:00,520 --> 00:04:01,870
Now what is the gotcha over here?

66
00:04:01,900 --> 00:04:07,390
Well, keep in mind that we're only updating the property, correct?

67
00:04:07,690 --> 00:04:13,900
So first of all, you will have to pull them all out from the rack that body in order to update them.

68
00:04:14,150 --> 00:04:16,329
So one by one, you'll have to set them up.

69
00:04:16,690 --> 00:04:20,649
Otherwise, I mean, you can pass the data, but it's not going to update the job.

70
00:04:20,980 --> 00:04:27,970
So it may showcase that I'm going to go back to my post, man once say that I'm going to send back the

71
00:04:27,970 --> 00:04:33,670
job education side, job location, and let's set it equal to a Mexico.

72
00:04:34,060 --> 00:04:36,700
And now let me ask you a million dollar question.

73
00:04:37,150 --> 00:04:42,580
You think in my response, job location is going to be my city or it's going to be Mexico.

74
00:04:43,210 --> 00:04:44,540
Of course, the answer is my city.

75
00:04:44,560 --> 00:04:44,950
Why?

76
00:04:45,370 --> 00:04:48,640
Well, because to update the property here now.

77
00:04:49,090 --> 00:04:53,680
So for every property, we'll have to pull it out from the dead body.

78
00:04:54,070 --> 00:04:55,330
First of all, you have to send it.

79
00:04:55,630 --> 00:05:00,190
And this is the case where, again, remember from the front end, we're sending all of them at the

80
00:05:00,190 --> 00:05:00,790
end of the day.

81
00:05:01,650 --> 00:05:08,520
Because we have them already inputs, so it might look a little bit and overexaggeration since we're

82
00:05:08,520 --> 00:05:10,470
just this thing going off in a postman right now.

83
00:05:10,740 --> 00:05:16,350
Keep in mind that, yes, of course, it also depends how you set up the front then and in our front,

84
00:05:16,350 --> 00:05:19,230
and we're sending all the properties regardless.

85
00:05:19,530 --> 00:05:20,520
Hopefully, that is clear.

86
00:05:20,820 --> 00:05:26,670
And now let me grab here the job location and I want to set it up here as well.

87
00:05:27,270 --> 00:05:34,350
So pretty much for every property that you have in the job model or whichever model you have.

88
00:05:34,650 --> 00:05:37,200
Yes, you'll have to set them up one by one.

89
00:05:37,710 --> 00:05:44,010
Unlike previously where we just updated the property that we're posting, hopefully about a square,

90
00:05:44,490 --> 00:05:50,190
and I'll let me change this one around where I'm going to go with job and location.

91
00:05:50,580 --> 00:05:54,600
Of course I'm Mr Rumpole, but should be job, location, like show.

92
00:05:55,050 --> 00:06:02,790
And also, we need to keep in mind that if, for example, we decide not to send any value and if we

93
00:06:02,790 --> 00:06:07,060
don't have on a property the default one, this will trigger the error.

94
00:06:07,110 --> 00:06:13,890
So let me show that first I'm going to go back to the man on Senate, and once we send the request,

95
00:06:13,890 --> 00:06:15,570
we should get back to Mexico.

96
00:06:16,050 --> 00:06:18,090
But I think I know where is this you?

97
00:06:18,180 --> 00:06:18,470
Yep.

98
00:06:18,780 --> 00:06:23,040
Of course, I wasn't particularly bright and I updated, they read me.

99
00:06:23,190 --> 00:06:28,110
So we need to go back to the day job and we need to pass in there.

100
00:06:28,110 --> 00:06:31,580
So go job, location and land.

101
00:06:31,620 --> 00:06:32,610
Copy and paste.

102
00:06:33,210 --> 00:06:35,280
And we're looking for this value over here as well.

103
00:06:35,550 --> 00:06:38,760
So let's go over here with job and location.

104
00:06:39,600 --> 00:06:40,260
Let's save it.

105
00:06:40,270 --> 00:06:41,880
Let's test it out one more time.

106
00:06:42,240 --> 00:06:45,090
And once we send it, everything is correct.

107
00:06:45,600 --> 00:06:53,520
And again, let me showcase something where if I'm not going to pass the job location altogether when

108
00:06:53,520 --> 00:06:56,980
it comes to find one and update, this is not going to be an issue.

109
00:06:57,240 --> 00:07:04,050
If, for example, I'm going to go back to a job and where I have the location, I'll remove the default

110
00:07:04,050 --> 00:07:06,510
one, then you'll see that right away.

111
00:07:06,900 --> 00:07:08,760
This will trigger here.

112
00:07:09,150 --> 00:07:12,480
So let me remove the default sitter and let my Senate.

113
00:07:12,870 --> 00:07:17,130
And right away you will notice path job location is required.

114
00:07:17,540 --> 00:07:20,250
Again, it's not going to be the case with fine when I'm up.

115
00:07:20,880 --> 00:07:28,140
So like I said, I will revert back to find one and update since I don't have any hooks in the job and

116
00:07:28,140 --> 00:07:29,510
you'll see how everything works.

117
00:07:29,520 --> 00:07:32,550
So let me take this one on commented.

118
00:07:32,790 --> 00:07:38,310
I will add check permissions because that is something that we'll work on in a second.

119
00:07:38,670 --> 00:07:42,080
And now we want to send back the update and job.

120
00:07:42,480 --> 00:07:48,990
And even if I don't have that before them will notice that once we send and in this case, let's just

121
00:07:48,990 --> 00:07:54,810
go with add it just so we can see that we're actually editing something, you'll notice that we still

122
00:07:54,810 --> 00:07:56,820
have that previous Mexico one.

123
00:07:57,270 --> 00:08:01,440
And hopefully this makes it clear where we have multiple approaches.

124
00:08:02,220 --> 00:08:07,050
So with one, we trigger the hooks with the find one and update we don't.

125
00:08:07,710 --> 00:08:12,390
So if you have some functionality that depends on on one, you'll have to go with second approach.

126
00:08:12,690 --> 00:08:19,500
But yes, when you use this approach, first of all, you'll have to make sure that the properties exist.

127
00:08:20,280 --> 00:08:27,090
Otherwise, if, for example, you're not passing the property and setting equal in the object, then

128
00:08:27,330 --> 00:08:28,380
there's going to be no update.

129
00:08:28,650 --> 00:08:36,030
And second, if you don't have the default values and in the model, this actually is required when

130
00:08:36,030 --> 00:08:36,890
you'll get the matter.

131
00:08:36,929 --> 00:08:37,350
Why?

132
00:08:37,679 --> 00:08:43,620
Well, because if I have here the job application, I'm pulling it out of that body.

133
00:08:44,039 --> 00:08:48,540
And if it's not provided with the request, this one will be undefined.

134
00:08:49,260 --> 00:08:54,300
And then I'm trying to set undefined where actually I'm looking for some kind of value.

135
00:08:55,320 --> 00:08:56,190
Keep that in mind.

136
00:08:56,460 --> 00:09:00,720
And now we can start working on check permissions functionality.

