1
00:00:00,270 --> 00:00:00,630
All right.

2
00:00:00,840 --> 00:00:08,070
And once we're familiar with the fundamentals now, let's see how can yours skip on the limit to set

3
00:00:08,070 --> 00:00:14,040
up deep education and not worry about the dollar jobs, as well as the number of pages?

4
00:00:14,840 --> 00:00:23,340
And first, we need to understand that when it comes to page and limit, we can pass them in and we

5
00:00:23,340 --> 00:00:26,760
will pass in the page from the front end.

6
00:00:27,030 --> 00:00:32,520
But first, since they're both query string parameters, they will be treated as strings.

7
00:00:33,030 --> 00:00:36,450
So first need to turn them into a number.

8
00:00:36,760 --> 00:00:38,670
And we use good old JavaScript for that.

9
00:00:39,030 --> 00:00:42,240
And second, we'll always have the default values.

10
00:00:42,630 --> 00:00:48,330
So if the page is not provided, I'll say that the user is looking for the page number one.

11
00:00:48,690 --> 00:00:51,750
Now that is the same default that we have on the frontend.

12
00:00:51,960 --> 00:00:53,520
So that should be already familiar.

13
00:00:53,760 --> 00:01:01,680
And the same goes with limit, where by default, I'll limit my response to 10 jobs per page.

14
00:01:02,730 --> 00:01:05,670
Yes, if you want, you can set it up on the front and different value.

15
00:01:06,060 --> 00:01:09,140
You can actually change that value so the user changes that power.

16
00:01:09,450 --> 00:01:11,580
But in our case, we'll just stick with this then.

17
00:01:11,970 --> 00:01:15,930
So while testing out in a postman, I'll show you how everything works.

18
00:01:15,930 --> 00:01:19,770
But in general, from the front end, we won't pass the limit.

19
00:01:19,860 --> 00:01:23,880
We'll just go with this default one, and the way we set up the functionality is like this.

20
00:01:23,910 --> 00:01:32,850
Instead of hard coding skip, we go with whatever is the page minus one and nine times the limit.

21
00:01:33,810 --> 00:01:36,420
So let's imagine that we have page number one.

22
00:01:36,570 --> 00:01:45,180
So one minus one is going to be zero zero times, the limit is going to be what it's going to be zero.

23
00:01:45,360 --> 00:01:47,880
So that's page number one shown here.

24
00:01:48,180 --> 00:01:50,010
We'll pass in the zero.

25
00:01:50,550 --> 00:01:57,150
And then since we have this limit of 10, we'll get back our first then items and I'll use my example

26
00:01:57,150 --> 00:01:58,650
where I have 75.

27
00:01:59,490 --> 00:02:02,010
So hopefully that is clear if this is zero.

28
00:02:02,190 --> 00:02:04,470
And then I have the limit of 10.

29
00:02:04,500 --> 00:02:05,970
I'll get back then items.

30
00:02:06,300 --> 00:02:09,960
So now let me showcase not just with the values that we currently have.

31
00:02:09,990 --> 00:02:12,360
So let me go to a job controller.

32
00:02:12,660 --> 00:02:16,120
I'll go with skip zero and nine.

33
00:02:16,140 --> 00:02:19,230
The limit will still be hardcoded as one Senate.

34
00:02:19,260 --> 00:02:22,760
Notice we start with our first company place.

35
00:02:22,770 --> 00:02:23,850
That was my scenario.

36
00:02:24,120 --> 00:02:27,970
And then I have total jobs then, which means that our functionality works.

37
00:02:28,500 --> 00:02:34,500
Now, if I want to get the second page, well, then the page value will be to the limit.

38
00:02:35,010 --> 00:02:36,170
Still be fine.

39
00:02:36,540 --> 00:02:41,550
That's the hardcoded value and not as far as skipping how many items that we're skipping.

40
00:02:41,910 --> 00:02:46,650
We're going to minus one, which is one times the limit, which is 10.

41
00:02:47,250 --> 00:02:51,030
So this value will be what it will be 10 over here.

42
00:02:51,300 --> 00:02:56,940
So we're shipping 10 items, and that's how we jump to the second page because we're still limiting

43
00:02:56,950 --> 00:02:59,190
Martin and one by one.

44
00:02:59,370 --> 00:03:01,210
So we set up the functionality again.

45
00:03:01,530 --> 00:03:03,630
We'll look for a page value by default.

46
00:03:03,630 --> 00:03:05,400
This is one we look for limit.

47
00:03:05,580 --> 00:03:07,770
By default, this is going to be 10.

48
00:03:08,190 --> 00:03:17,010
And in order to calculate skip, we subtract one from whatever is on the page and then multiply by limit,

49
00:03:17,460 --> 00:03:18,840
which in our case is 10.

50
00:03:19,140 --> 00:03:22,290
And then we pass in these two values and skip and limit.

51
00:03:22,590 --> 00:03:27,060
And as a result, we can get certain pages back.

52
00:03:27,390 --> 00:03:29,340
So let's try to set that one up.

53
00:03:29,520 --> 00:03:35,550
Where I'm going to go to jobs controller here, the moment I have hardcoded values.

54
00:03:35,760 --> 00:03:37,190
So it's change that one around them.

55
00:03:37,320 --> 00:03:38,940
First, let's start with that page.

56
00:03:39,360 --> 00:03:45,180
So page, let's go with no, that's passing Eric Query and the page.

57
00:03:45,360 --> 00:03:49,680
If you're wondering, well, why you're grabbing us from the query, why don't you go over here and

58
00:03:49,680 --> 00:03:50,340
just pull out?

59
00:03:50,730 --> 00:03:52,080
Well, you can definitely do so.

60
00:03:52,500 --> 00:03:58,770
But I already have the variable by the name of Page, and I just find this one easier if nothing is

61
00:03:58,770 --> 00:03:59,070
there.

62
00:03:59,580 --> 00:04:02,640
And by default, we're going to be getting with the first page.

63
00:04:02,970 --> 00:04:04,980
Let's copy and paste now.

64
00:04:05,070 --> 00:04:07,560
In this case, I have a limit of 10 or a move that one.

65
00:04:08,530 --> 00:04:14,380
And let's do the same thing over here, where limit is equal to wreck, query and limit.

66
00:04:14,750 --> 00:04:19,209
And I know I said this before, but from our front end we'll actually won't sign it.

67
00:04:19,269 --> 00:04:25,480
If you want to set up that functionality or indefinitely or so and we'll start with eight, then so

68
00:04:25,480 --> 00:04:26,530
that's the default one.

69
00:04:26,920 --> 00:04:32,740
And then let's set up that skip, let's say, page minus one and nine times the limit.

70
00:04:33,070 --> 00:04:35,470
That's the whole logic behind it.

71
00:04:35,650 --> 00:04:41,350
Let's save it, and let's start out where I'm going to go here, where I'm setting up the where certain

72
00:04:41,360 --> 00:04:46,750
parameters I'm going to say page and I want for time being is going to be equal to a one.

73
00:04:47,350 --> 00:04:53,290
And then as far as the element, well, let's go with that then same one, the default.

74
00:04:53,300 --> 00:04:57,700
Then once we send, I'm going to get back, then jobs and notice again.

75
00:04:57,700 --> 00:04:58,960
This is going to be my first one.

76
00:04:59,740 --> 00:05:05,440
I'm not going to show you page by page, but I just want to show that if I'm going to go with page number

77
00:05:05,440 --> 00:05:08,530
eight, I'm only going to get five hours.

78
00:05:08,560 --> 00:05:08,950
Why?

79
00:05:09,190 --> 00:05:11,350
Well, because I have 75 total.

80
00:05:12,100 --> 00:05:15,310
So if we go over here, if we send, check it out.

81
00:05:15,340 --> 00:05:18,580
Now I have only five jobs total.

82
00:05:19,480 --> 00:05:26,590
I got off my showcase that here were the numbers where I go here with eight one eight minus one is seven.

83
00:05:26,950 --> 00:05:29,320
Seven times the limit is 70.

84
00:05:29,530 --> 00:05:34,300
So we're skipping 70 items and we're limiting to 10.

85
00:05:34,690 --> 00:05:40,840
Now, since we get back, only five doesn't really matter, since it's not bigger than the limit.

86
00:05:41,060 --> 00:05:46,810
And if you want to change this around, let's say that we're going to go with page number one and then

87
00:05:46,870 --> 00:05:48,580
we're looking for twenty five.

88
00:05:49,030 --> 00:05:54,010
Now, since the limit is twenty five, now we actually have three pages.

89
00:05:54,370 --> 00:05:58,600
So if we're going to go here with four, you'll notice that we get back nothing.

90
00:05:58,970 --> 00:05:59,300
Correct.

91
00:05:59,370 --> 00:06:06,700
Again, 75 divided by limit of 25 is three pages and then we can go one by one and get those pages one,

92
00:06:06,700 --> 00:06:08,950
two three and then the fourth page.

93
00:06:09,160 --> 00:06:10,780
We already don't have any items.

94
00:06:11,020 --> 00:06:17,770
Hopefully this is square and now we can deal with total jobs as well as number of pages.

