1
00:00:00,330 --> 00:00:00,760
Beautiful.

2
00:00:00,780 --> 00:00:06,450
And once we can set up the access token dynamically in the postman, of course, let's keep on working

3
00:00:06,450 --> 00:00:07,140
on our route.

4
00:00:07,530 --> 00:00:10,350
And next one up, we have got a job.

5
00:00:10,680 --> 00:00:15,510
And I think this is going to be the case where I'll actually log in back in as Anna.

6
00:00:15,900 --> 00:00:19,540
So where I have the log in use around, I'll just go with Anna.

7
00:00:19,710 --> 00:00:21,180
Now, of course, I get this token.

8
00:00:21,420 --> 00:00:27,630
Just because she has more jobs helped me save all of these routes since I don't want to set up everything

9
00:00:27,630 --> 00:00:28,800
from scratch.

10
00:00:29,340 --> 00:00:33,390
And once I have logged in as Anna, let me just double check.

11
00:00:33,690 --> 00:00:34,550
Got all the jobs.

12
00:00:34,570 --> 00:00:34,760
Yep.

13
00:00:35,100 --> 00:00:36,090
I have four of them.

14
00:00:36,360 --> 00:00:40,560
And then remember, four get job one will need to pass.

15
00:00:40,920 --> 00:00:43,910
Of course that is going to be the route Paramor.

16
00:00:44,070 --> 00:00:44,450
Correct.

17
00:00:44,800 --> 00:00:49,350
This is where we'll provide the and if you want to double check that, just go back to the routes.

18
00:00:49,350 --> 00:00:51,450
We're looking for jobs one and notice.

19
00:00:51,690 --> 00:00:55,170
So the post and get all jobs is for the road.

20
00:00:55,500 --> 00:00:58,890
And then we have the ports and then Colan.

21
00:00:58,890 --> 00:01:05,640
And then of course this is going to be that route parameter which will get me that single job, make

22
00:01:05,640 --> 00:01:08,790
sure that I can delete one as well as update one.

23
00:01:09,210 --> 00:01:14,640
And not to start whether our basic functionality works, essentially, whether we can get that silly

24
00:01:14,640 --> 00:01:17,280
string, we need to go back to the postman.

25
00:01:17,610 --> 00:01:23,130
And I think I will just leave the log user one and then I'll open up a new tab.

26
00:01:23,430 --> 00:01:25,260
We're looking for get request, of course.

27
00:01:25,740 --> 00:01:33,330
Then we go over here with our URL and line ports and this is where I want to pass in the area so and

28
00:01:33,360 --> 00:01:37,760
get all jobs as far as the response, of course, will get back there.

29
00:01:37,800 --> 00:01:38,690
That is correct.

30
00:01:38,940 --> 00:01:45,380
And now if I want that one single job, I just need to take underscore again, you're not looking for

31
00:01:45,390 --> 00:01:46,110
a user here.

32
00:01:46,440 --> 00:01:47,850
You're looking for answers.

33
00:01:47,860 --> 00:01:50,340
Corradi, which just signals a job.

34
00:01:50,910 --> 00:01:52,800
So copy this one line.

35
00:01:52,800 --> 00:01:57,120
Go back to the get one and one will get the single request.

36
00:01:57,330 --> 00:02:00,480
And remember, we still need to go with my authorization.

37
00:02:00,840 --> 00:02:02,400
We need to set up their token.

38
00:02:02,610 --> 00:02:04,640
And of course, we'll use the access token.

39
00:02:04,950 --> 00:02:09,740
And once we send if everything is correct, of course we should get around.

40
00:02:09,750 --> 00:02:14,940
Doesn't exist because I was pretty smart and I forgot to the jobs one.

41
00:02:15,270 --> 00:02:18,390
So let's go over here and let's say jobs.

42
00:02:18,390 --> 00:02:22,140
And then once we send now, of course, we have to get a single job.

43
00:02:22,440 --> 00:02:24,420
So we know that this functionality works.

44
00:02:24,750 --> 00:02:27,630
And of course, now we just need to go back to our controller.

45
00:02:27,900 --> 00:02:31,410
And in here I'm going to be looking for two things in request.

46
00:02:31,770 --> 00:02:37,890
First, we need to remember that as far as the jobs, we can access it in the program's object, that's

47
00:02:37,890 --> 00:02:38,640
going to be the job.

48
00:02:39,390 --> 00:02:44,910
And when it comes to user, of course, that one is located in the user object that we're getting from

49
00:02:44,910 --> 00:02:45,450
the middleware.

50
00:02:45,690 --> 00:02:51,540
So that's the structure, both of these things, because as our functionality gets more complex, I

51
00:02:51,540 --> 00:02:55,860
think it's easier if we can clearly see where we're getting those values from.

52
00:02:56,130 --> 00:02:59,100
So I'm going to structure my request object.

53
00:02:59,340 --> 00:03:01,140
And in there I'm looking for two things.

54
00:03:01,380 --> 00:03:03,150
I'm looking for the user object.

55
00:03:03,360 --> 00:03:06,780
And I remember in the user object, I have the user ID.

56
00:03:06,960 --> 00:03:09,900
So now of course, we're doing the master the structuring.

57
00:03:10,080 --> 00:03:11,550
So I'm looking for that first.

58
00:03:11,940 --> 00:03:13,980
And then what I want is the param.

59
00:03:13,980 --> 00:03:17,340
So this one, of course, is provided by the Express.

60
00:03:17,580 --> 00:03:20,930
And then more specifically, we're looking for Daddy now.

61
00:03:20,940 --> 00:03:24,540
Why we're looking for it because that's how I called it over here.

62
00:03:24,780 --> 00:03:33,120
And since I want to have more clarity on which one is which are right away, give it an alias of job

63
00:03:33,120 --> 00:03:33,960
ID like.

64
00:03:33,960 --> 00:03:35,700
So so now we have both.

65
00:03:35,940 --> 00:03:38,370
We have the job ready from the programs.

66
00:03:38,850 --> 00:03:41,010
So this one is coming from here.

67
00:03:41,280 --> 00:03:49,170
And then since we have the access token now, of course we can also access the ID of Anna online.

68
00:03:49,440 --> 00:03:57,660
Simply a logic of finding that one job where the ID is the job as well as created by is equal to the

69
00:03:57,660 --> 00:03:58,040
user.

70
00:03:58,710 --> 00:04:05,640
And if the job doesn't exist, the final error, because remember, we have two types of error.

71
00:04:05,880 --> 00:04:14,730
Either will get a casting error where the syntax doesn't match to that of the Mongo's object or simply

72
00:04:14,910 --> 00:04:18,140
we just pass in some kind of wrong job idea.

73
00:04:18,390 --> 00:04:21,570
And then, of course, if everything is correct, then we send back the job.

74
00:04:21,930 --> 00:04:22,920
So let's try it out.

75
00:04:22,920 --> 00:04:27,540
We are going to be looking for a job and I will be equal to await, of course.

76
00:04:27,810 --> 00:04:32,490
Then we go with our model name and then we go find one that's the method name.

77
00:04:32,730 --> 00:04:40,410
And in here in the filter object, we pass in underscore ID, which is equal to our job at first.

78
00:04:40,620 --> 00:04:45,330
Now, of course, in here the order is not important, but we do want to check for both.

79
00:04:45,600 --> 00:04:49,710
Otherwise somebody can just get the ID and then they can access the job.

80
00:04:50,070 --> 00:04:55,740
So let's go to created by and we'll set it equal to our user ID.

81
00:04:56,100 --> 00:04:59,130
And then like I said, we have two options for errors.

82
00:04:59,700 --> 00:05:04,710
We have a casting error, which will handle a little bit later as far as the nice responses, or we

83
00:05:04,710 --> 00:05:13,140
simply have a case where we provided some wrong ID and or simply check that by saying if there is no

84
00:05:13,140 --> 00:05:15,380
job, then we'll throw on your error.

85
00:05:15,660 --> 00:05:22,070
And of course, we're looking for not found one and then we'll pass in the actual text.

86
00:05:22,410 --> 00:05:23,420
We have the job.

87
00:05:23,760 --> 00:05:28,650
So let's say no job with ID and instead of using templates, turn back.

88
00:05:28,650 --> 00:05:32,700
And right away I said and I'm going to be looking for my job right now.

89
00:05:32,700 --> 00:05:36,760
If everything is correct, then of course we'll get back the entire job.

90
00:05:37,080 --> 00:05:44,460
So say here resident status, which we're looking for our status codes, then we'll go with OK, and

91
00:05:44,460 --> 00:05:47,570
then we'll go with Jason and we'll send back the job.

92
00:05:47,880 --> 00:05:54,090
And of course, we can just start out in our postman where instead of this get single job, I should

93
00:05:54,300 --> 00:05:56,070
get the job that matches that do.

94
00:05:56,310 --> 00:05:58,180
In this case, I'm going to go on.

95
00:05:58,530 --> 00:06:05,190
So now let me double check where I have all the jobs and I'm going to be looking for while these ones

96
00:06:05,190 --> 00:06:06,530
technically are both the same.

97
00:06:06,900 --> 00:06:13,620
So let me look for Apple one and I'll grab the idea that the job I can keep that in mind.

98
00:06:13,620 --> 00:06:14,850
That is very, very important.

99
00:06:15,120 --> 00:06:17,360
We're not looking for what was writing.

100
00:06:18,150 --> 00:06:23,160
And once I said, of course, I should get back to Apple, and if you get the same results, then of

101
00:06:23,160 --> 00:06:25,890
course we can move on to our next step.

