WEBVTT 00:03.360 --> 00:08.880 So we have a database function now to get patinated results and we have to update our handler and we're 00:08.880 --> 00:11.370 going to have to update it a couple of times, but let's get started. 00:11.400 --> 00:19.740 So the handler in question is all sales in handler's dash API go, and right now all it does is just 00:20.190 --> 00:21.540 get all orders. 00:21.580 --> 00:22.490 Well, we don't want to do that. 00:22.500 --> 00:25.290 We actually want to query a subset of the orders. 00:25.290 --> 00:30.120 So I'm going to assume that we're going to, first of all, receive some Jason as part of the payload 00:30.370 --> 00:34.290 while creating our payload, which will be a struct. 00:34.530 --> 00:37.040 And it will have a couple of things passed to us. 00:37.140 --> 00:39.520 First of all, page size, which will be an end. 00:40.260 --> 00:43.980 And in Jason, that's page underscore size. 00:44.160 --> 00:52.890 And we're also going to get what page are we looking at, Current Page and Jason Page. 00:53.730 --> 00:55.430 OK, we'll save that. 00:56.070 --> 00:57.700 And of course, we have to unmerciful. 00:58.590 --> 01:09.360 So let's call error is a sign the value of after Jason and we're handing it over and we're on martialing 01:09.360 --> 01:11.900 into payload and we'll check for an error. 01:12.000 --> 01:15.870 So a copy of this code and paste it here. 01:18.300 --> 01:21.840 And now we need to change this to use get all orders patinated. 01:23.610 --> 01:25.860 And of course, that returns more than two things. 01:25.860 --> 01:32.100 It returns all sales plus the last page, which will be an end and the total number of records, total 01:32.100 --> 01:34.500 records and then a comma and. 01:37.400 --> 01:43.850 And we need to pass this couple of values, so just to get it to work up a two and one in there, so 01:43.850 --> 01:44.740 that'll make a compile. 01:46.250 --> 01:49.340 Now we need to use our last page and our total records. 01:49.340 --> 01:54.740 And what we're going to do with that is write some Jason back to the user that includes more than just 01:54.740 --> 01:55.480 ourselves. 01:55.580 --> 02:03.980 So let's create a struct or create a variable resp that is just trapped and it'll have certain information, 02:04.160 --> 02:07.870 current page, which will be end. 02:08.330 --> 02:11.870 And in JSON, we'll call that current underscore page. 02:13.850 --> 02:17.300 It will also have page size, which is an eight. 02:18.140 --> 02:24.770 And in JSON, we're going to call that page size and also last page, 02:28.220 --> 02:30.200 which will be around and in JSON. 02:30.560 --> 02:37.400 We'll call that last underscore page and we want the total number of records. 02:37.400 --> 02:44.090 So Total Records, which is also an end and adjacent, I'll call that total underscore records. 02:45.950 --> 02:56.000 And finally, we want to include orders, which will be a slice of pointer of model's order. 02:58.670 --> 03:02.120 Now, less populated values rest on current page. 03:02.760 --> 03:03.830 It's going to be equal to one. 03:04.370 --> 03:05.240 Let's just hardcoded. 03:05.240 --> 03:06.290 We'll fix that later on. 03:06.950 --> 03:12.050 Restaffed page size will be haloed 03:15.890 --> 03:18.590 page size rasped. 03:18.800 --> 03:26.570 Last page will be equal to last page we got from a function called just up above resp dot. 03:27.890 --> 03:34.250 Total records is going to be equal to total records which again we got from our function call and finally 03:34.250 --> 03:46.010 restored orders will be equal to all sales and now we'll write out instead of all sales rest and that 03:46.010 --> 03:46.760 should get it working. 03:47.000 --> 03:50.810 OK, now there are some hard coded values in there that we'll have to update at some point. 03:51.230 --> 03:55.310 But for right now, I just want to get to the point where I can make a call to this handler from the 03:55.310 --> 03:59.180 front end and see that I'm getting some data back and will improve it after that. 03:59.210 --> 04:00.020 Let's move on.