So we have a database function now to get patinated results and we have to update our handler and we're
going to have to update it a couple of times, but let's get started.
So the handler in question is all sales in handler's dash API go, and right now all it does is just
get all orders.
Well, we don't want to do that.
We actually want to query a subset of the orders.
So I'm going to assume that we're going to, first of all, receive some Jason as part of the payload
while creating our payload, which will be a struct.
And it will have a couple of things passed to us.
First of all, page size, which will be an end.
And in Jason, that's page underscore size.
And we're also going to get what page are we looking at, Current Page and Jason Page.
OK, we'll save that.
And of course, we have to unmerciful.
So let's call error is a sign the value of after Jason and we're handing it over and we're on martialing
into payload and we'll check for an error.
So a copy of this code and paste it here.
And now we need to change this to use get all orders patinated.
And of course, that returns more than two things.
It returns all sales plus the last page, which will be an end and the total number of records, total
records and then a comma and.
And we need to pass this couple of values, so just to get it to work up a two and one in there, so
that'll make a compile.
Now we need to use our last page and our total records.
And what we're going to do with that is write some Jason back to the user that includes more than just
ourselves.
So let's create a struct or create a variable resp that is just trapped and it'll have certain information,
current page, which will be end.
And in JSON, we'll call that current underscore page.
It will also have page size, which is an eight.
And in JSON, we're going to call that page size and also last page,
which will be around and in JSON.
We'll call that last underscore page and we want the total number of records.
So Total Records, which is also an end and adjacent, I'll call that total underscore records.
And finally, we want to include orders, which will be a slice of pointer of model's order.
Now, less populated values rest on current page.
It's going to be equal to one.
Let's just hardcoded.
We'll fix that later on.
Restaffed page size will be haloed
page size rasped.
Last page will be equal to last page we got from a function called just up above resp dot.
Total records is going to be equal to total records which again we got from our function call and finally
restored orders will be equal to all sales and now we'll write out instead of all sales rest and that
should get it working.
OK, now there are some hard coded values in there that we'll have to update at some point.
But for right now, I just want to get to the point where I can make a call to this handler from the
front end and see that I'm getting some data back and will improve it after that.
Let's move on.