Hey, did everybody this year and this video we're going to finally walk through with some of the rejects
that we studied in the half hour video into this one.
So we need to just extract the values which can be numbers like greater than the pricing, greater than
the ratings, less than the rating and so on, and something like this.
Now for this one, I would like to bring your attention to one very, very important thing, which is
the order.
Now, order of these very clause is super important.
For example, let's just say you have directly added the order of limiting and skipping and then you
are trying to search for your result.
It's not going to be good.
You obviously need to first put up the result or first put up the search query at the first that whatever
the user is trying to search, maybe there are 100 products which says code.
So you obviously want to grab all those products out of, let's just say 1000 products and then put
a limit and a skip feature on that.
Not first put up a skip feature and all of that and then bring up the search results.
So obviously order really matters a lot.
But what we're going to do in this one is actually kind of a work through with this one.
Now, so far we have seen that the search keyword, which is again, we saw that this is a big, gigantic
object.
Inside the object, there are key value pairs.
So the couple of key value pairs that we are not interested now in is the search and this page field.
Precisely.
And there might be also a limit field that comes in which we haven't talked about.
So let's go ahead and say that there can be something like and a limit equals to maybe five.
This is arbitrary value here.
So there can be more of these.
But right now this is the three things that is coming to my mind.
So search page and limit.
So these are the three things which we are not bothered about.
Rest of all the things like category.
Yeah, this is okay.
This is fine.
We can search based on the category, something like this.
A category equals to whatever the category name comes.
And that is fine ratings for all of these.
Rest of the remaining things we need to actually go ahead and add a dollar sign between GTI, LTE or
if you are supporting GTI or LTE only.
So that we need to do let's go ahead and work on with that.
So this is going to be another method.
Feel free to add it wherever you like.
So this method is responsible for kind of filtering the product.
So this is actually the proper name of this functionality.
So filtering up on the product based on the kind of operator, again in case you want to go more in
depth of it, this is where they call it up.
So let me go ahead and search for this.
You can just go for a GTI and look for it.
So these are the GTI, all of that.
So let me open this up.
So these are aggregation.
So instead of the filter, they like to call it as aggregation and all of that again, really a mouthful.
So that's why I call them as rather filter.
So in this filter, first thing that we are going to do is we are going to have a copy of this big query.
Now you might be wondering why copy in this one we have worked on directly, other ones we have worked
on directly by this one, because I told you that we have to inject some of the Reg X applications and
reg X works only with the string.
So I don't want to manipulate the additional string into a JSON, then string then again adjacent.
So I want to have a copy of this just for the caution purpose.
So I'm going to go ahead and say let's just go ahead and grab a copy of this one.
So we are going to go ahead and say copy queue for the copy query.
And this is going to come up to me from this dot, whatever the big query is.
So we're going to go ahead and say B query.
Now, surely this is going to work in, but maybe at the time of filtering you might have added more
things.
It's not really compulsory that it might be coming up from search, only it might be having something
more so rather having this one.
We are going to spread this out.
And remember, this is not an error, this is an object.
So I'm going to go ahead and spread this one.
And finally after that, we're going to go ahead now to result per page.
We're going to go ahead and say this dot big query what this will allow it that whatever the existing
values are let keeping them.
I just want to hold them up into a variable.
Now further down the road, I have to remove some fields.
So what I'm going to do to remove the fields, I'm going to go ahead and say, let's go ahead and remove
inside this one, my copy string.
Let's go ahead and run a function delete because it's not like a that I can pop out a value or something.
I have to use the delete keyword.
Now inside this query I want to look for a key value pair.
So this is how we look for a key value pair.
And I'm looking for the first keyword, which is a search itself.
So whatever that value is, go ahead and delete that and make sure you put up a colon here automatically.
It's going to come in.
But I just want to go with that.
So what else we got?
So we have got the search keyword being delete.
Now we want to delete this page and we want to delete this limit also.
So there we go.
We're going to go ahead and two copies.
So let's go ahead and say, hey, I want to delete the limit and I want to go ahead and delete this
page as well and something that we messed up.
These are the key value.
So they are going to go inside this like this.
So that actually deletes the value, not treat them as available.
If you have more fields coming into that, all you've got to do is simply go up and remove that.
Now, this is the most readable code that you can have that, hey, somebody is copying this and somebody
is removing some of the fields inside the BigQuery.
Now, the only thing that's remaining to us is something like this.
The category is going to be there, the rating is going to be there, and the price values are going
to be there.
The next thing that I have to do is I have to use a regex to inject a dollar in place of GTI or whatever
you are supporting.
I cannot do it right now because right now this is an object, so I need to convert that into a string.
So I'm going to go ahead and convert big queue into a string and I'm holding this one actually inside
copy.
Q Now, because again, we don't want to manipulate the original one, so how we can do that.
So we're going to say that let create a variable and we are going to call this one as a string of big
Q.
There we go.
So big query.
Not big query, actually the copy query that we are going to convert now.
So copy.
So string of copy how we are going to go ahead and do that.
Again, really simple.
JSON has the option to string ify anything.
So let's go ahead and pass on this one.
So we're going to pass on this copy query, copy that and pass it up here.
Now, in theory, the string of copy query is now a string, obviously, as the name says.
And all I have to do is run a regex through that.
So we won't be creating a new variable into that.
We will be just storing everything inside this one.
So we're going to go ahead and say, hey, string, copy, you are going to go ahead and run a method
for me.
So string copy, string copy of Q really a weird name, but it actually defines what exactly it is.
We're going to go ahead and simply use that place.
And in here we are going to inject some of the forward slashes.
So there we go.
So this is where my regex is going to go in and I'm going to use a G keyword for for having a global
access of that.
And what do you want to do?
Remember I told you that whatever we are matching in, we are going to use the tactics.
And further down the road, I'm going to go ahead and say I want to use back tax dollar.
Whatever you match, you just go ahead and add a dollar in front of it.
Remember, we have already talked about this in the long rally video, so this is all good.
Now what we've got to do is simply add some values into this one.
So we're going to go ahead and wrap this up around and we told I told you that we'll be saying GTI or
LTE, but there are cases that sometimes people don't use the GTI.
They also use just the greater than equal to.
Again, this needs to be conveyed to your front end developer that are you using GTI or what you are
sending to me, but I'll just add all of them.
So GTI and I'll also say that hey, there can be an LD less than I usually don't prefer all four of
them.
I only prefer two of them either go through with the greater than and equal to or prefer greater than
equal to like either the first two pairs or use the last two pair.
This is really good for the application and we also saw a weird syntax that it actually matches everything.
So we are going to add a boundary, so we're going to add the boundary all the way up.
So slash B we've already gone through with the result that how it works on.
In case you don't, then go ahead and look for the demo test video where we worked quite a lot in depth
of it.
So this is all good.
Now we have a string, which is exactly how we want it with the dollar sign and everything.
Okay, so moving on now, this string again needs to be converted into a JSON here.
So let's go ahead and do that.
So I'm going to go ahead and say this is my JSON of.
Uh, copy cue.
Now, let's go ahead and add a simple letter here.
Although we can go ahead and work on with the cost because we are not going to be changing it further
down the road.
I can go ahead and say, hey, Jason, just go ahead and pass.
What do you want to pass?
I want to pass on this a string of copy.
Q Okay.
Now further down the road, I'm holding this exactly the way I want to have it.
Now, again, we are doing all of this.
I hope you understand that.
Why we are removing all the fields and replacing all of that, and we are also now taking care of that,
this one here.
So this will have no impact at all.
This will be as it is passed on as a parameter onto this one.
Okay, so this is all good.
Now let's go ahead and add this one.
So we're going to say, hey, this dot base is going to be equal to this dot base.
And further, we're going to just chain in a dot find.
And in here we're going to go ahead and say that, hey, I want to go ahead and add this JSON copy of
Q really, really amazing.
And by the way, in case you didn't notice, we can actually go ahead and pass on as many common values
as you wish.
So in here you can just pass on all these mode values.
Again, read the documentation a little bit more for that.
So this couldn't be much more easier than this.
I know this filter is actually a little bit tricky that we have worked on, but I think the code is
very, very self explanatory.
Anything that you are going to find in any online version and by the way, you can find this exact thing
on the GitHub like probably in hundreds and hundreds of project, but I think this is the most a little
bit wider and a longer code, but this is much more explainable than anything else that you can find.
Okay, so this is all good.
Now, finally, our very clause is ready and you can use it in any of the all the models, even in the
user model itself, accidentally wrote that even in the in the user model products model category,
model orders model, whatever you have, you can use this as a test because this is so much kind of
abstractly written that you have to just pass on the base wherever you are having product, base or
base user, base, user find, product, find whatever you have and just pass me on this BigQuery.
I hope these comments will help you to understand it a little bit more.
That's it for this one.
Let's go ahead and catch up in the next one.