WEBVTT

00:03.820 --> 00:08.470
Hey, did everybody this year and this video we're going to finally walk through with some of the rejects

00:08.470 --> 00:11.020
that we studied in the half hour video into this one.

00:11.020 --> 00:16.420
So we need to just extract the values which can be numbers like greater than the pricing, greater than

00:16.420 --> 00:19.600
the ratings, less than the rating and so on, and something like this.

00:19.690 --> 00:24.490
Now for this one, I would like to bring your attention to one very, very important thing, which is

00:24.490 --> 00:25.510
the order.

00:25.510 --> 00:28.640
Now, order of these very clause is super important.

00:28.660 --> 00:33.490
For example, let's just say you have directly added the order of limiting and skipping and then you

00:33.490 --> 00:35.450
are trying to search for your result.

00:35.470 --> 00:37.090
It's not going to be good.

00:37.120 --> 00:42.070
You obviously need to first put up the result or first put up the search query at the first that whatever

00:42.070 --> 00:46.180
the user is trying to search, maybe there are 100 products which says code.

00:46.180 --> 00:50.680
So you obviously want to grab all those products out of, let's just say 1000 products and then put

00:50.710 --> 00:53.440
a limit and a skip feature on that.

00:53.440 --> 00:58.030
Not first put up a skip feature and all of that and then bring up the search results.

00:58.030 --> 01:00.460
So obviously order really matters a lot.

01:00.460 --> 01:04.720
But what we're going to do in this one is actually kind of a work through with this one.

01:05.080 --> 01:10.420
Now, so far we have seen that the search keyword, which is again, we saw that this is a big, gigantic

01:10.420 --> 01:11.020
object.

01:11.020 --> 01:13.180
Inside the object, there are key value pairs.

01:13.180 --> 01:19.570
So the couple of key value pairs that we are not interested now in is the search and this page field.

01:19.570 --> 01:20.530
Precisely.

01:20.530 --> 01:24.730
And there might be also a limit field that comes in which we haven't talked about.

01:24.730 --> 01:32.290
So let's go ahead and say that there can be something like and a limit equals to maybe five.

01:32.320 --> 01:33.820
This is arbitrary value here.

01:33.820 --> 01:35.590
So there can be more of these.

01:35.680 --> 01:39.010
But right now this is the three things that is coming to my mind.

01:39.010 --> 01:41.290
So search page and limit.

01:41.290 --> 01:44.250
So these are the three things which we are not bothered about.

01:44.260 --> 01:46.330
Rest of all the things like category.

01:47.320 --> 01:48.220
Yeah, this is okay.

01:48.250 --> 01:48.850
This is fine.

01:48.850 --> 01:51.130
We can search based on the category, something like this.

01:51.130 --> 01:53.980
A category equals to whatever the category name comes.

01:53.980 --> 01:56.860
And that is fine ratings for all of these.

01:56.860 --> 02:03.220
Rest of the remaining things we need to actually go ahead and add a dollar sign between GTI, LTE or

02:03.220 --> 02:05.800
if you are supporting GTI or LTE only.

02:05.800 --> 02:08.980
So that we need to do let's go ahead and work on with that.

02:08.980 --> 02:10.660
So this is going to be another method.

02:10.840 --> 02:12.490
Feel free to add it wherever you like.

02:12.550 --> 02:16.780
So this method is responsible for kind of filtering the product.

02:16.780 --> 02:20.980
So this is actually the proper name of this functionality.

02:20.980 --> 02:27.580
So filtering up on the product based on the kind of operator, again in case you want to go more in

02:27.580 --> 02:29.950
depth of it, this is where they call it up.

02:29.950 --> 02:31.840
So let me go ahead and search for this.

02:31.840 --> 02:35.200
You can just go for a GTI and look for it.

02:35.200 --> 02:37.720
So these are the GTI, all of that.

02:37.720 --> 02:39.880
So let me open this up.

02:39.880 --> 02:41.440
So these are aggregation.

02:41.440 --> 02:45.820
So instead of the filter, they like to call it as aggregation and all of that again, really a mouthful.

02:45.820 --> 02:48.250
So that's why I call them as rather filter.

02:48.250 --> 02:53.560
So in this filter, first thing that we are going to do is we are going to have a copy of this big query.

02:53.590 --> 02:57.760
Now you might be wondering why copy in this one we have worked on directly, other ones we have worked

02:57.760 --> 03:04.000
on directly by this one, because I told you that we have to inject some of the Reg X applications and

03:04.000 --> 03:06.010
reg X works only with the string.

03:06.010 --> 03:11.140
So I don't want to manipulate the additional string into a JSON, then string then again adjacent.

03:11.140 --> 03:14.440
So I want to have a copy of this just for the caution purpose.

03:14.560 --> 03:18.760
So I'm going to go ahead and say let's just go ahead and grab a copy of this one.

03:18.760 --> 03:22.420
So we are going to go ahead and say copy queue for the copy query.

03:22.420 --> 03:29.260
And this is going to come up to me from this dot, whatever the big query is.

03:29.260 --> 03:31.180
So we're going to go ahead and say B query.

03:31.210 --> 03:37.900
Now, surely this is going to work in, but maybe at the time of filtering you might have added more

03:37.900 --> 03:38.110
things.

03:38.110 --> 03:42.580
It's not really compulsory that it might be coming up from search, only it might be having something

03:42.580 --> 03:45.250
more so rather having this one.

03:45.250 --> 03:47.110
We are going to spread this out.

03:47.110 --> 03:49.300
And remember, this is not an error, this is an object.

03:49.300 --> 03:51.250
So I'm going to go ahead and spread this one.

03:51.250 --> 03:55.120
And finally after that, we're going to go ahead now to result per page.

03:55.120 --> 04:01.180
We're going to go ahead and say this dot big query what this will allow it that whatever the existing

04:01.180 --> 04:03.130
values are let keeping them.

04:03.130 --> 04:05.860
I just want to hold them up into a variable.

04:05.980 --> 04:08.710
Now further down the road, I have to remove some fields.

04:08.710 --> 04:14.650
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

04:14.650 --> 04:17.590
inside this one, my copy string.

04:18.370 --> 04:25.450
Let's go ahead and run a function delete because it's not like a that I can pop out a value or something.

04:25.450 --> 04:27.250
I have to use the delete keyword.

04:27.370 --> 04:30.790
Now inside this query I want to look for a key value pair.

04:30.790 --> 04:32.710
So this is how we look for a key value pair.

04:32.710 --> 04:35.680
And I'm looking for the first keyword, which is a search itself.

04:35.680 --> 04:40.720
So whatever that value is, go ahead and delete that and make sure you put up a colon here automatically.

04:40.720 --> 04:41.410
It's going to come in.

04:41.410 --> 04:42.970
But I just want to go with that.

04:42.970 --> 04:44.290
So what else we got?

04:44.290 --> 04:46.450
So we have got the search keyword being delete.

04:46.450 --> 04:49.960
Now we want to delete this page and we want to delete this limit also.

04:50.260 --> 04:51.730
So there we go.

04:51.760 --> 04:53.650
We're going to go ahead and two copies.

04:53.950 --> 04:58.390
So let's go ahead and say, hey, I want to delete the limit and I want to go ahead and delete this

04:58.390 --> 05:00.790
page as well and something that we messed up.

05:00.790 --> 05:01.780
These are the key value.

05:02.080 --> 05:04.870
So they are going to go inside this like this.

05:06.060 --> 05:09.480
So that actually deletes the value, not treat them as available.

05:09.510 --> 05:14.670
If you have more fields coming into that, all you've got to do is simply go up and remove that.

05:14.700 --> 05:18.690
Now, this is the most readable code that you can have that, hey, somebody is copying this and somebody

05:18.690 --> 05:20.940
is removing some of the fields inside the BigQuery.

05:21.000 --> 05:23.640
Now, the only thing that's remaining to us is something like this.

05:23.640 --> 05:28.140
The category is going to be there, the rating is going to be there, and the price values are going

05:28.140 --> 05:28.800
to be there.

05:29.550 --> 05:37.440
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

05:37.440 --> 05:38.180
you are supporting.

05:38.190 --> 05:42.720
I cannot do it right now because right now this is an object, so I need to convert that into a string.

05:42.720 --> 05:51.570
So I'm going to go ahead and convert big queue into a string and I'm holding this one actually inside

05:51.870 --> 05:52.270
copy.

05:52.290 --> 05:56.820
Q Now, because again, we don't want to manipulate the original one, so how we can do that.

05:56.820 --> 06:04.770
So we're going to say that let create a variable and we are going to call this one as a string of big

06:04.770 --> 06:05.280
Q.

06:06.090 --> 06:06.780
There we go.

06:06.810 --> 06:07.920
So big query.

06:07.920 --> 06:11.490
Not big query, actually the copy query that we are going to convert now.

06:11.910 --> 06:13.080
So copy.

06:13.080 --> 06:15.540
So string of copy how we are going to go ahead and do that.

06:15.540 --> 06:16.470
Again, really simple.

06:16.470 --> 06:19.050
JSON has the option to string ify anything.

06:19.050 --> 06:20.940
So let's go ahead and pass on this one.

06:20.940 --> 06:25.290
So we're going to pass on this copy query, copy that and pass it up here.

06:25.410 --> 06:30.840
Now, in theory, the string of copy query is now a string, obviously, as the name says.

06:30.840 --> 06:33.600
And all I have to do is run a regex through that.

06:33.600 --> 06:36.540
So we won't be creating a new variable into that.

06:36.540 --> 06:38.730
We will be just storing everything inside this one.

06:38.730 --> 06:43.050
So we're going to go ahead and say, hey, string, copy, you are going to go ahead and run a method

06:43.050 --> 06:43.440
for me.

06:43.440 --> 06:50.160
So string copy, string copy of Q really a weird name, but it actually defines what exactly it is.

06:50.520 --> 06:52.950
We're going to go ahead and simply use that place.

06:53.010 --> 06:57.090
And in here we are going to inject some of the forward slashes.

06:57.090 --> 06:58.170
So there we go.

06:58.170 --> 07:04.980
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

07:04.980 --> 07:05.850
access of that.

07:05.970 --> 07:07.620
And what do you want to do?

07:07.620 --> 07:11.910
Remember I told you that whatever we are matching in, we are going to use the tactics.

07:12.360 --> 07:17.820
And further down the road, I'm going to go ahead and say I want to use back tax dollar.

07:18.360 --> 07:22.830
Whatever you match, you just go ahead and add a dollar in front of it.

07:22.830 --> 07:28.860
Remember, we have already talked about this in the long rally video, so this is all good.

07:28.860 --> 07:33.000
Now what we've got to do is simply add some values into this one.

07:33.000 --> 07:39.270
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

07:39.720 --> 07:44.550
LTE, but there are cases that sometimes people don't use the GTI.

07:44.820 --> 07:46.770
They also use just the greater than equal to.

07:46.770 --> 07:52.530
Again, this needs to be conveyed to your front end developer that are you using GTI or what you are

07:52.530 --> 07:55.350
sending to me, but I'll just add all of them.

07:55.350 --> 08:02.160
So GTI and I'll also say that hey, there can be an LD less than I usually don't prefer all four of

08:02.160 --> 08:02.370
them.

08:02.370 --> 08:06.740
I only prefer two of them either go through with the greater than and equal to or prefer greater than

08:06.750 --> 08:11.160
equal to like either the first two pairs or use the last two pair.

08:11.190 --> 08:17.130
This is really good for the application and we also saw a weird syntax that it actually matches everything.

08:17.130 --> 08:20.970
So we are going to add a boundary, so we're going to add the boundary all the way up.

08:20.970 --> 08:24.900
So slash B we've already gone through with the result that how it works on.

08:24.900 --> 08:29.430
In case you don't, then go ahead and look for the demo test video where we worked quite a lot in depth

08:29.430 --> 08:29.910
of it.

08:30.660 --> 08:31.620
So this is all good.

08:31.620 --> 08:36.300
Now we have a string, which is exactly how we want it with the dollar sign and everything.

08:36.810 --> 08:43.290
Okay, so moving on now, this string again needs to be converted into a JSON here.

08:43.290 --> 08:45.330
So let's go ahead and do that.

08:45.330 --> 08:50.820
So I'm going to go ahead and say this is my JSON of.

08:52.000 --> 08:53.750
Uh, copy cue.

08:55.030 --> 08:58.080
Now, let's go ahead and add a simple letter here.

08:58.090 --> 09:02.110
Although we can go ahead and work on with the cost because we are not going to be changing it further

09:02.110 --> 09:02.830
down the road.

09:02.860 --> 09:06.550
I can go ahead and say, hey, Jason, just go ahead and pass.

09:06.550 --> 09:07.600
What do you want to pass?

09:07.600 --> 09:10.600
I want to pass on this a string of copy.

09:10.630 --> 09:11.600
Q Okay.

09:11.710 --> 09:15.640
Now further down the road, I'm holding this exactly the way I want to have it.

09:15.670 --> 09:17.110
Now, again, we are doing all of this.

09:17.110 --> 09:18.130
I hope you understand that.

09:18.130 --> 09:22.900
Why we are removing all the fields and replacing all of that, and we are also now taking care of that,

09:22.900 --> 09:23.620
this one here.

09:23.620 --> 09:25.540
So this will have no impact at all.

09:25.540 --> 09:29.470
This will be as it is passed on as a parameter onto this one.

09:29.950 --> 09:31.150
Okay, so this is all good.

09:31.150 --> 09:32.470
Now let's go ahead and add this one.

09:32.470 --> 09:40.210
So we're going to say, hey, this dot base is going to be equal to this dot base.

09:40.870 --> 09:44.130
And further, we're going to just chain in a dot find.

09:44.140 --> 09:49.630
And in here we're going to go ahead and say that, hey, I want to go ahead and add this JSON copy of

09:49.630 --> 09:51.970
Q really, really amazing.

09:51.970 --> 09:56.980
And by the way, in case you didn't notice, we can actually go ahead and pass on as many common values

09:56.980 --> 09:57.690
as you wish.

09:57.700 --> 10:00.400
So in here you can just pass on all these mode values.

10:00.400 --> 10:02.980
Again, read the documentation a little bit more for that.

10:03.100 --> 10:05.170
So this couldn't be much more easier than this.

10:05.170 --> 10:09.670
I know this filter is actually a little bit tricky that we have worked on, but I think the code is

10:09.670 --> 10:11.140
very, very self explanatory.

10:11.140 --> 10:15.700
Anything that you are going to find in any online version and by the way, you can find this exact thing

10:15.700 --> 10:20.980
on the GitHub like probably in hundreds and hundreds of project, but I think this is the most a little

10:20.980 --> 10:26.560
bit wider and a longer code, but this is much more explainable than anything else that you can find.

10:26.820 --> 10:27.990
Okay, so this is all good.

10:28.000 --> 10:34.150
Now, finally, our very clause is ready and you can use it in any of the all the models, even in the

10:34.150 --> 10:40.210
user model itself, accidentally wrote that even in the in the user model products model category,

10:40.210 --> 10:45.820
model orders model, whatever you have, you can use this as a test because this is so much kind of

10:45.820 --> 10:50.560
abstractly written that you have to just pass on the base wherever you are having product, base or

10:50.740 --> 10:56.530
base user, base, user find, product, find whatever you have and just pass me on this BigQuery.

10:56.530 --> 10:59.680
I hope these comments will help you to understand it a little bit more.

10:59.890 --> 11:00.970
That's it for this one.

11:00.970 --> 11:02.830
Let's go ahead and catch up in the next one.
