All right.
And up next, let's complete Get All Jobs page.
More specifically, we're going to work on the search functionality as well as the pagination.
Now, when it comes to search functionality, we're going to use query params, also known as URL parameters,
or they're also called query strings.
So lots of names, but essentially they're used to pass information to a web server through the URL
of the web page.
Now they're typically appended to the end of the URL after the question mark and separated by ampersands.
Query parameters consist of key value pairs.
Where the key represents the parameter name, and then the value represents the corresponding data being
passed, and they're commonly used in the web applications to provide additional context or parameters
to a server.
So if we navigate to a complete project, look for get all jobs, look for search form and just change
any of these values over here.
So this is totally up to you.
You can provide your search term or you can just go with different status.
Notice once we do that.
We refresh the page.
And what's more interesting now in the URL, we have this question mark and we have a long list of query
strings.
And essentially they are separated by key value pairs.
And now on a server we process them and based on this value we actually return jobs.
So now check it out.
Since I looked for pending, now I'm only getting the jobs where the status is pending.
So this is what we're going to set up.
As you can see, we have one, two, three, four values that we want to use.
So one is going to be for search then the job status and job type.
Pretty straightforward.
Basically, I'll search based on the job status and job type and also we'll add the sort option where
I can go, for example, with A to Z and Z to A and newest and oldest like always, we're going to start
on a server.
And first, I guess let's understand two important things.
First, how we can pass them in the Thunder client, the query parameter, and second, how we can access
on the server.
Now of course, eventually we'll work on the front end and then I'll show you how we can pass it in
the front end.
But the server side is not going to change.
Once we understand how we can access them, we're going to be good to go.
So for starters, let's go to get all jobs request.
So once we make the request, we should get some jobs back.
And in my case, since I populated the database for John, I have tons of jobs back and check it out.
We can either type the query string over here manually.
Basically I can type question mark and then provide the key value pair.
And then of course, if I have multiple the ampersand or we can use nicely here this query tab and then
check it out.
Basically we're right away.
Get the name for the parameter and also we can set up the value.
So let's try over here.
I'm going to type search since that's the value we're going to use and I'm going to stick with that.
And then as far as the value.
Well, for starters, we're not going to have any regex functionality.
Basically, we're only going to get jobs that match.
Exactly.
And therefore, in my case, I'm going to look for position and I'm going to pick one of the jobs.
So I want to make sure that it matches.
Exactly.
So let me go, I guess, with this one, since the name is somewhat short.
So let me copy this over here.
So now let me open up the integrated terminal.
Then let's hop over to job controller.
And in order to access those query params, we want to go here with log and then req and query so it's
not params.
So those were the URL parameters.
When we're looking for query parameters, we go with req dot query and now check it out.
I'll save it.
Now let's navigate back, make the request and notice something interesting.
So I have here this search.
So I'm getting the object.
And of course in here I have the value.
And you can probably already imagine that the more parameters we're going to add.
Yes, all of them are going to be over here as properties.
So now let's put two and two together.
We have a search, some kind of value that we're getting eventually from the front end.
And now on the server, we have this find and in here we have the filter object.
We could use that search value in order to search for specific jobs.
For example, since I'm using position, I could say, you know what?
Not only get.
The jobs where the user ID matches whatever I have coming in, but also look for position and let's
set it equal to rec dot query and search.
Yes, of course, eventually we'll use regex and all that.
But if everything is correct, I should get at least this one job where position is equal to this value.
So let's try it out.
I'm going to go back to get all jobs.
Let's make the request and now check it out.
I get back this one job because of course, now I was searching for a specific position.
And with this in place now we can work on the more complex setup.