WEBVTT

00:03.910 --> 00:05.310
Hey, did everyone that they share?

00:05.320 --> 00:08.980
And in this video, we're going to have a revision of the JavaScript.

00:09.070 --> 00:12.850
Now, in case you think that you are an absolute pro in JavaScript, you don't need this video, then

00:12.850 --> 00:14.590
you can absolutely skip this one.

00:14.590 --> 00:17.620
This has nothing to do with the course just except one thing.

00:17.950 --> 00:21.360
Let me just walk you through with that one thing and then you'll be absolutely free.

00:21.370 --> 00:22.270
So in the product.

00:22.270 --> 00:26.560
JS What we have done is we have used these dashes inside the enum.

00:26.560 --> 00:31.480
When we are setting up the categories, I later on realize that these dashes can actually give us some

00:31.480 --> 00:31.900
problems.

00:31.900 --> 00:34.750
So I'm going to go ahead and remove all these dashes.

00:34.900 --> 00:39.730
Now, usually you can go ahead in the front end, can use the dashes or even spaces, whatever you like.

00:39.730 --> 00:45.010
But I think when these values are going to come to us, they might create some issues, not compulsory,

00:45.010 --> 00:45.670
but they might.

00:45.670 --> 00:50.770
It was bothering me a little bit because sometimes these dashes and spaces are too much are encoded.

00:50.770 --> 00:51.490
I don't want that.

00:51.490 --> 00:52.300
So that's why.

00:52.540 --> 00:56.710
Okay, so this is the main part of the thing that is about or related with the course.

00:56.710 --> 00:58.930
Now next step is the JavaScript basics.

00:59.110 --> 01:03.280
I have realized that a lot of people don't really understand some of the concept of the JavaScript and

01:03.280 --> 01:05.560
that actually bothers them throughout the course.

01:05.560 --> 01:09.850
In this video, I'll walk you through with one of the such incident, which is throughout the industry

01:09.850 --> 01:12.730
is being used, which is one to replace method.

01:12.730 --> 01:16.660
I will walk you through what happens and how it can be utilized and further more on that.

01:16.840 --> 01:17.360
Okay.

01:17.830 --> 01:21.100
So we're going to first start by having a basic file.

01:21.100 --> 01:24.130
So first let's get a simple file inside the util folder.

01:24.130 --> 01:25.480
It's not going to be useful.

01:25.480 --> 01:30.760
It's going to be a simple new file, which is going to be simply a demo test.

01:31.090 --> 01:36.760
JS Okay, so this is the basic file that we have, and I'm going to be just writing some gibberish code

01:36.760 --> 01:37.150
in this.

01:37.150 --> 01:41.530
These codes are not going to actually run, but this is important for understanding perspective.

01:41.650 --> 01:46.480
Now what we have so far seen that whenever we have modeled something like user or product or whatever,

01:46.480 --> 01:48.640
we have this method of find.

01:48.730 --> 01:51.130
Now in the find so far we have passed on nothing.

01:51.130 --> 01:56.740
That means an empty parenthesis, or sometimes we don't even pass on that when we don't pass on anything.

01:56.740 --> 01:59.410
This means that we are passing in an empty selector here.

01:59.410 --> 02:02.590
Now this is where usually the query goes in of the MongoDB.

02:02.590 --> 02:07.360
In case you remember, we sometimes actually worked on something like this that, hey, when the email

02:07.360 --> 02:12.100
equals to email or something like this, or in this case we were writing just the email.

02:12.130 --> 02:18.010
Now the idea behind that is that if I want to find a user which is having an email of, let's just say

02:18.010 --> 02:22.600
hit at the rate AE dev, it's going to give me all of that.

02:22.600 --> 02:27.820
Now in case if you remember, we used similar kind of property when we were working on the models.

02:28.090 --> 02:29.470
Let me show you that again.

02:29.470 --> 02:35.410
Inside the user controller for the manager especially, we wrote that I want to find everybody who's

02:35.410 --> 02:36.670
role is user.

02:36.670 --> 02:40.780
So I can definitely go ahead and find the user based on this query.

02:40.900 --> 02:46.140
Now so far we have seen that I can find all the users who are having role some particular email, very

02:46.190 --> 02:48.280
restrictive on that or everybody like that.

02:48.370 --> 02:50.800
But there is a little bit more to it.

02:50.800 --> 02:53.020
Let me show you that on the documentation.

02:53.020 --> 02:57.580
If you will read the MongoDB manual itself, you are going to see that we have some of the comparison

02:57.580 --> 02:59.020
query operator as well.

02:59.050 --> 03:06.160
These query operator are remarkably helpful in all of the cases they have equals greater than greater

03:06.160 --> 03:15.880
than equal to in then less than less than equal to then we have got nine not in and this one is.

03:15.880 --> 03:16.930
This one is.

03:16.930 --> 03:17.560
What was that?

03:17.560 --> 03:18.190
I forgot.

03:18.340 --> 03:20.020
Okay, not equal.

03:20.020 --> 03:25.120
So there's a lot of things available up here majority of the time that we use.

03:25.120 --> 03:30.580
Is this not in that if you want to check whether something some of the values is inside that area or

03:30.580 --> 03:31.030
not.

03:31.030 --> 03:33.880
But in this case, we are going to use only the phone here.

03:34.390 --> 03:38.890
In fact, some of the time I have seen majorly to being used greater than end the less than these are

03:38.890 --> 03:41.560
two, but we are going to be using greater than equal to also.

03:41.560 --> 03:46.780
So what happens in this case you can see in the greater then notice here they are saying DB don't inventory

03:46.780 --> 03:48.190
don't bother too much on that.

03:48.190 --> 03:53.920
Just remember we have this find method and inside this fine method we have the same parenthesis and

03:53.920 --> 03:55.930
inside that we have these curly braces.

03:55.930 --> 03:59.080
Inside this curly braces we are passing on a quantity.

03:59.080 --> 04:02.140
And then this quantity also goes into the curly braces.

04:02.140 --> 04:07.330
And then we go ahead and say, hey, dollar greater than all these operators actually need to pass on

04:07.330 --> 04:08.080
as dollar.

04:08.080 --> 04:13.150
So this dollar is really, really important and we go ahead and say, hey, this should be greater than

04:13.150 --> 04:17.530
20, so you need to search for something whose quantity is greater than 20.

04:17.530 --> 04:22.810
So this is really, really helpful and all the other things actually works almost exactly the same.

04:22.810 --> 04:25.120
You don't need to probably study them too much.

04:25.120 --> 04:26.950
You just need to just glance over them.

04:26.950 --> 04:31.570
So this one is going to be exactly same, but it's also going to match the equality as well.

04:31.570 --> 04:36.940
So if the quantity is 20, it's going to return that then we have less than and you guessed it right,

04:36.940 --> 04:40.510
it's it works exactly same and we have less than equal to as well.

04:40.510 --> 04:45.040
They work exactly same as you might be expecting them returning the value which is less than or equal

04:45.040 --> 04:46.720
to the 20 in this case.

04:47.170 --> 04:48.280
So this is all clear.

04:48.370 --> 04:48.930
Okay.

04:49.300 --> 04:52.120
Now moving on, coming back onto the code part.

04:52.840 --> 04:56.560
So we're going to go ahead and comment this out that we understand this much better part.

04:56.590 --> 04:58.810
Now, coming back on to the user controller.

04:58.810 --> 05:01.570
So this is the basic user controller that we have.

05:01.690 --> 05:02.920
We don't want to work on the user.

05:02.920 --> 05:03.480
We want to work.

05:03.630 --> 05:04.920
The model controller.

05:04.920 --> 05:09.240
So if I can find not model product controller, my bad.

05:09.330 --> 05:12.570
All I want to do here is I want to show that how it looks like.

05:12.570 --> 05:17.010
So I'm going to go ahead and simply say, hey, log me all the requests to dot query.

05:17.520 --> 05:22.880
So anything that's coming up into the query format, I just want to go ahead and see how it looks like.

05:22.890 --> 05:25.020
And this needs to go above.

05:25.050 --> 05:25.450
There you go.

05:25.470 --> 05:26.460
Now it's all happy.

05:26.790 --> 05:31.220
So anything that is going to come up into the question mark format is going to come in.

05:31.230 --> 05:36.210
So how this query actually looks like we are going to be reaching to the slash API, obviously slash

05:36.210 --> 05:38.690
V1, whatever is your path in this case.

05:38.700 --> 05:42.600
And then maybe you're searching for user or maybe you're searching for product.

05:42.900 --> 05:48.900
Now most of the application, when you are searching for maybe a shopping website, maybe a travel booking

05:48.900 --> 05:54.240
website, go AB or whatever you are searching for a hotel product, whatever you are searching for.

05:54.270 --> 05:59.070
The first thing is actually search and anything after the question mark is actually a query.

05:59.070 --> 06:00.430
So this is the by default.

06:00.450 --> 06:06.690
So what happens is inside the search, you pass on a kind of a a word that you are looking for, searching

06:06.690 --> 06:09.540
probably a simple string or something.

06:09.540 --> 06:11.460
So in our case, let's just say something.

06:11.460 --> 06:13.650
Someone is searching for a code related t shirt.

06:13.650 --> 06:16.590
So I'm going to say code or code or whatever you like to say this one.

06:16.650 --> 06:22.410
So now this can be a long string and change with the plus keyword and however you want to separate them.

06:22.410 --> 06:26.310
But in this case, we are going to be just choosing one word, just for an example.

06:27.000 --> 06:32.010
Now, not only that, there is one more keyword up here, so we use to separate these keywords and in

06:32.010 --> 06:34.560
person sign, this is how the query is being crafted.

06:34.620 --> 06:37.500
Now here you're going to see there is a keyword again, there is a page.

06:37.500 --> 06:40.040
So page can be equal to one or maybe two.

06:40.050 --> 06:43.400
So whatever you are doing, one or two, something like this.

06:43.410 --> 06:49.380
So sometimes you restrict the products that I don't want to show entirety of 200 or 2000 products on

06:49.380 --> 06:51.750
my website, I want to separate them on the page.

06:51.750 --> 06:53.340
So pagination goes in there.

06:53.340 --> 06:57.060
So you want to get a product on page number two, page number one or something like that.

06:57.060 --> 06:59.430
So this is also comes in as a query part.

06:59.520 --> 07:03.630
Now, not only that, sometimes you have, let's just say a category as well.

07:03.630 --> 07:06.480
So you go ahead and filter it out based on the category.

07:06.490 --> 07:11.430
So I'm going to go ahead and say, hey, category is equals to and then we go ahead and say this one

07:11.430 --> 07:13.740
is short sleeves.

07:13.740 --> 07:15.510
So this is the category as well.

07:15.540 --> 07:18.570
Further down the road, a user also wants to see that.

07:18.570 --> 07:26.100
I want to have only the t shirts whose rating is above four or maybe above three.

07:26.100 --> 07:31.320
So in that case, what we can do is we can go ahead and say, hey, rating and equals to four.

07:31.350 --> 07:35.800
Now how you actually craft this URL or this query is up to you.

07:35.820 --> 07:41.160
Now, usually a lot of people prefer to just get it as like rating equals to four and do all the manipulation

07:41.160 --> 07:42.870
on per root method.

07:42.870 --> 07:46.800
But you can actually go ahead and say something like this inside this bracket.

07:46.800 --> 07:49.560
You can say rating greater than or equal to four.

07:49.560 --> 07:52.470
So this is up to you what you pass on inside the rating.

07:52.470 --> 07:56.850
So at the time of in the front end itself, how you are crafting is heavily going to be depends.

07:56.850 --> 08:02.130
So this information needs to be 100% passed on to somebody who is playing in the front end.

08:02.160 --> 08:06.630
So again, in this case, let's just say we are going to go ahead and say that we accept parameters

08:06.630 --> 08:07.560
in this format.

08:07.560 --> 08:10.080
So user will be selecting just the four and three.

08:10.080 --> 08:13.650
But the way how this is going to be crafted in the front end is going to be like this.

08:13.650 --> 08:17.620
So inside the squared brackets, we just go ahead and grab get.

08:17.730 --> 08:22.800
There is a simple and very important role of why we are crafting that into a square bracket.

08:24.030 --> 08:26.670
Now, further down the road, this is not enough for me.

08:26.670 --> 08:28.860
I would like to have a little bit more of the query.

08:28.860 --> 08:34.080
So I'm going to go ahead and say, put another person and I'm going to say I want to restrict the pricing

08:34.080 --> 08:34.650
as well.

08:34.650 --> 08:42.150
So I'm going to go ahead and say, hey, pricing should be, let's just say, less than or equal to.

08:42.840 --> 08:50.100
I am looking for less than equal to maybe nine, nine, nine and I need to move that on to the just

08:50.100 --> 08:50.730
like that.

08:51.330 --> 08:54.510
And I can actually just for making sure you understand the things.

08:54.510 --> 08:55.650
I'll move this one here.

08:56.280 --> 09:00.740
And pricing is less than or equal to nine, nine, nine.

09:00.750 --> 09:03.480
And I also want to select the starter range as well.

09:03.510 --> 09:13.050
And price price is also going to be greater than or equal to 199.

09:13.050 --> 09:14.520
So you are looking for a range.

09:14.520 --> 09:20.370
So yes, this kind of complex query is very absolutely normal thing to deal with that this is the reason

09:20.370 --> 09:25.080
why we are actually working on the product in the email we have done with a different kind of complexity

09:25.080 --> 09:29.700
about the tokens and all these stuffs, but this is also another kind of complexity that works on and

09:29.700 --> 09:30.690
goes through with that.

09:30.720 --> 09:35.310
Now, as complex as your product is going to be, these queries may become a little bit longer as well.

09:35.310 --> 09:38.220
This is a very common phenomenon that happens quite a lot.

09:38.430 --> 09:39.000
Okay.

09:39.000 --> 09:42.660
So how we why this is important for us to discuss this part?

09:42.690 --> 09:43.800
It is very important.

09:43.800 --> 09:47.100
First, I want to walk you through with a little bit onto the other thing.

09:47.100 --> 09:54.960
So I'll take you on to a website which is an Mozilla developer network here, Mozilla developer, kind

09:54.960 --> 09:55.710
of a blog.

09:56.010 --> 09:56.210
Okay.

09:56.280 --> 09:58.770
So this is the page where the demo is the string replace.

09:58.770 --> 09:59.640
We have already seen that.

09:59.640 --> 10:03.330
How it works on it gives you to example there is a quick brown fox a.

10:03.380 --> 10:09.200
Example here it says console.log in this entire paragraph, just replace the dog with a monkey.

10:09.590 --> 10:10.220
We got that.

10:10.220 --> 10:11.480
We'll get the result here.

10:11.480 --> 10:18.290
And also, it gives you an example of regex or regular expression in which you replace the dog with

10:18.290 --> 10:19.160
the ferret.

10:19.490 --> 10:20.780
Let's see how it works on.

10:20.780 --> 10:22.350
So we see the two output here.

10:22.370 --> 10:25.520
The quick brown fox jumps over the lazy monkey.

10:25.610 --> 10:28.610
So notice here this time it says p dot replace.

10:28.610 --> 10:33.200
So the first time it says it sees the dog, it replaces it with the monkey.

10:33.620 --> 10:34.220
Acceptable.

10:34.250 --> 10:35.180
Totally doable.

10:35.420 --> 10:38.210
In the second case, the p dot replace.

10:38.210 --> 10:41.680
It says wherever you see the dog first time, just replace it with the ferret.

10:41.690 --> 10:44.330
So both of them are giving you the exact same result.

10:45.620 --> 10:47.750
We're not going to be using it this long example.

10:47.750 --> 10:53.030
We'll be actually crafting this example, something that we actually like to know and we like to work

10:53.030 --> 10:53.390
on.

10:53.390 --> 10:59.870
So we'll be having a GTI, GTI and LTY, so greater than equal to greater than equal to end LTE.

10:59.870 --> 11:05.210
But we just saw that they alone doesn't work like GTI and XLT and in the URL itself you cannot pass

11:05.210 --> 11:05.590
$1.

11:05.630 --> 11:11.180
It will automatically get converted into URL and coded just like space is converted into person 20.

11:11.420 --> 11:14.990
So the problem is the query that I'll be receiving up here.

11:14.990 --> 11:18.200
Notice here what we are sending here is having a GTI.

11:18.230 --> 11:20.240
Now I need to first worry about that.

11:20.240 --> 11:22.550
How can I make it as a dollar GTI?

11:22.550 --> 11:26.870
Because that is the query I can go ahead and pass on here in the email segment.

11:26.870 --> 11:29.330
Remember, let me just copy this line up here.

11:29.330 --> 11:34.010
So if I need to pass on something like this, this is important for me to convert that.

11:34.220 --> 11:37.220
So let me go back up here and inside this example.

11:37.220 --> 11:39.860
We are going to go ahead and paste this one.

11:39.860 --> 11:45.080
So now if I want to pass on this quantity, I have to pass on as dollar to 20.

11:45.080 --> 11:52.160
So the challenge one itself is to how to replace this price with something like price dollar GTI because

11:52.160 --> 11:53.990
dollar is not coming to me and shouldn't be.

11:53.990 --> 11:58.340
This is also a security risk, so let's go ahead and work out with that.

11:59.000 --> 12:01.940
So I'll go into this one and we have this GTI now.

12:01.940 --> 12:04.730
We have seen something like this replace already in the past.

12:04.730 --> 12:10.310
We have seen that we were looking for something like better and then this pace and we were saying that

12:10.310 --> 12:13.760
hey, whatever comes in, just go ahead and use like this.

12:13.760 --> 12:16.520
So what it does actually, it gives me just the empty token.

12:16.520 --> 12:17.390
We have already seen that.

12:17.390 --> 12:18.440
Very understandable.

12:18.710 --> 12:19.490
Nothing big deal.

12:19.490 --> 12:21.830
We are going to go ahead and remove this entirely.

12:21.980 --> 12:27.140
We're going to focus rather on the regex itself this time that how we can use the regex and do some

12:27.140 --> 12:27.650
stuff.

12:27.650 --> 12:31.940
So instead of the dog itself, I'm going to go ahead and say I want to look for GTI.

12:31.970 --> 12:37.070
Remember, two slashes are really important for these regex and then slash, I will see that what it

12:37.070 --> 12:40.220
actually works or not and how it actually works with that.

12:40.220 --> 12:41.330
Let's run this one.

12:42.350 --> 12:45.080
So it replaces whatever it finds it with the ferret.

12:45.080 --> 12:46.640
I don't want a ferret like this.

12:46.640 --> 12:50.540
I would rather like to convert that into a dollar GTI.

12:50.750 --> 12:56.150
The ultimate goal is not to just put a dollar on GTI, but actually on all of them GTI.

12:56.180 --> 12:57.170
Then again GTI.

12:57.170 --> 13:00.560
Then I want to put a dollar in front of all of them.

13:00.560 --> 13:06.080
So if I go ahead and do this right now, it, it places the dollar at one of the keyword, but not all

13:06.080 --> 13:06.650
of them.

13:06.770 --> 13:10.970
So I'm somewhere there, but it's not doing the job, all the places.

13:11.240 --> 13:13.790
Now, what if I just go ahead and add all of them?

13:13.790 --> 13:16.910
Let's just say I add LTE, also LTE.

13:17.000 --> 13:19.490
So obviously this is not a correct string.

13:19.490 --> 13:20.390
So what if I do?

13:20.390 --> 13:22.580
I put up a or statement in between them.

13:22.580 --> 13:23.810
Let's go ahead and run this.

13:24.080 --> 13:24.420
Okay.

13:24.440 --> 13:28.100
Now it's still it says, hey, I'm putting it up on the GTI, not on the LTE.

13:28.100 --> 13:30.320
So clearly this is not working.

13:30.320 --> 13:34.730
But let me break it to you already that no matter what you're going to do, you're going to use the

13:34.730 --> 13:35.630
OR character.

13:35.630 --> 13:41.240
So I'm going to go ahead and say, hey, GTI or you find LTE or whatever is the matching keyword you

13:41.240 --> 13:41.960
are looking for.

13:41.960 --> 13:46.310
But the problem with the regex is they are too quick to actually give you the output result.

13:46.550 --> 13:51.170
They actually go ahead and find whatever the first character is and they replace it with this guy.

13:51.620 --> 13:53.360
But there is another problem here.

13:53.360 --> 13:57.740
We have all of them, but this is not giving this is where the another magic of this comes in.

13:58.040 --> 14:01.880
Now, what you can do, this replace is a really complex one.

14:01.880 --> 14:06.710
So whatever the regex you are matching for, you can actually kind of throw a callback here.

14:06.710 --> 14:11.300
So whatever it matches, it actually gives you as a kind of a function back and you can just fire up

14:11.300 --> 14:16.280
a callback and into this whatever you can, you can actually return that or whatever.

14:16.280 --> 14:21.140
For example, if I just go ahead and say test, I go ahead and run that it says, Hey, test is not

14:21.140 --> 14:21.530
defined.

14:21.530 --> 14:24.770
So we actually can replace that with some kind of a string here.

14:24.890 --> 14:26.570
Let's go ahead and do that with it.

14:26.780 --> 14:31.700
Test a string and run that again and notice that the there it says test.

14:31.880 --> 14:34.160
Now, I don't want to replace it with the test.

14:34.160 --> 14:37.970
Obviously I want to replace it with the dollar GTI.

14:38.000 --> 14:41.250
Okay, let's go ahead and do that one by $1 GTI.

14:41.420 --> 14:42.260
Run that.

14:42.260 --> 14:43.850
Okay, this one is working fine.

14:43.850 --> 14:49.910
Now only thing I need to worry about is I need to figure out that how can I place dollar in front of

14:49.910 --> 14:50.480
all of them?

14:50.480 --> 14:52.310
How can I match all of these guys?

14:52.310 --> 14:58.070
Okay, so the first thing to do in all of that is I have to replace this I with G.

14:58.070 --> 14:59.570
G stands for Global.

14:59.570 --> 15:03.170
If I run this one now, it says, okay, you have a dollar GTI you.

15:03.230 --> 15:04.970
Every dollar and you have a dollar.

15:05.720 --> 15:07.400
So what happened this time?

15:07.400 --> 15:10.190
Whatever the first match is, it just replaces all of them.

15:10.190 --> 15:14.150
With these guys, we can actually go ahead and change this one.

15:14.150 --> 15:17.090
The reason why I'm writing em here, because this is a variable here.

15:17.090 --> 15:18.350
I can use a variable.

15:19.130 --> 15:24.290
So I'm going to go ahead and say, hey, remove this one and use a back tactics and the back text.

15:24.290 --> 15:30.350
I can say simply dollar and this, this is how we declare variable in them and we are going to go ahead

15:30.350 --> 15:35.990
and save match and I'm going to go ahead and say a match and after that I'm going to go ahead and write

15:35.990 --> 15:37.220
test just to show you.

15:37.490 --> 15:40.850
I notice here it says g t test, g t test and l t test.

15:40.850 --> 15:44.180
So whatever all it is matching in the global now this is being used.

15:44.180 --> 15:48.290
But this test is actually just to show you this is not how we are going to use that.

15:48.290 --> 15:52.970
What we want to do after the dollar is variable, but we want to add an additional dollar just like

15:52.970 --> 15:53.690
we added a test.

15:53.690 --> 15:56.660
After that, we're going to go ahead and use a dollar before it.

15:56.660 --> 15:58.160
I'm going to go ahead and run this.

15:58.190 --> 16:03.320
Okay, so now it looks like my problem is solved so I can have a dollar g t, dollar g, t t.

16:03.350 --> 16:06.560
So whatever the cases I want to batch, I can go ahead and use that.

16:06.560 --> 16:08.030
But there is a small problem.

16:08.030 --> 16:12.620
What if in the future something comes up as my g t.

16:13.160 --> 16:16.670
So if that comes in notice here it says my dollar.

16:17.660 --> 16:21.920
Okay, so this is just a kind of an odd case that we are facing up here.

16:21.920 --> 16:26.090
And in case you have worked any time in the past with these rejects, you know that these are really,

16:26.090 --> 16:27.470
really tricky one to handle.

16:27.470 --> 16:32.750
So in this case, what you can do is first, you can wrap whatever you want to match up here just like

16:32.750 --> 16:32.960
this.

16:32.960 --> 16:38.390
So wrap them in the parenthesis and then you can go ahead and simply define a boundary for the boundary.

16:38.390 --> 16:40.040
The slash B is being used.

16:40.040 --> 16:46.310
Now, if I run this one, it only matches either the values on the start or at the very end of it.

16:46.310 --> 16:49.160
And not not like end end of it.

16:49.160 --> 16:54.620
Like the string should start with only anything after that or previous that is not going to be converted.

16:54.620 --> 16:58.400
So we are strictly matching for just the values that you have given to me.

16:58.640 --> 17:03.080
Now it works in majority of the cases, but in the case of JavaScript, I have noticed that there is

17:03.080 --> 17:07.520
a slash B at the end of it is also required in some cases actually fails out.

17:07.520 --> 17:11.540
So the slashing are a trailing slash B again, this is same for boundaries.

17:11.540 --> 17:12.740
It is being required.

17:12.740 --> 17:18.260
So now whatever you pass on into this string, this is going to be converted as the matching string.

17:18.260 --> 17:21.380
So this is going to be very helpful for us in the future cases.

17:21.680 --> 17:22.110
Okay.

17:22.760 --> 17:28.130
So we have done a lot of detailed discussion about how regex works and how we can replace the values

17:28.130 --> 17:30.650
and how this actually gives you a method and all of that.

17:30.660 --> 17:34.970
In fact, if you're going to read all of this, this is all written up here that hey, actually this

17:34.970 --> 17:37.130
replace is a function replacement and all of that.

17:37.130 --> 17:38.660
So yeah, this is all written up here.

17:38.660 --> 17:41.330
It's not something I'm coming up magically out of the air.

17:41.870 --> 17:44.660
Okay, so this is all done coming back onto the code part.

17:44.690 --> 17:49.550
Now one problem is solved that I can go ahead and into this string.

17:49.550 --> 17:52.940
I can go ahead and inject dollar at every single piece of this.

17:53.150 --> 17:58.790
But in reality, this is really important to see up here.

17:59.000 --> 18:03.350
When I say quantity, for example, I'll say, okay, price or not price.

18:03.350 --> 18:06.260
Actually, in this case, yeah, we can actually use price.

18:06.260 --> 18:10.490
So I want to say price and price should be greater than 199.

18:10.490 --> 18:16.220
So how I'm going to craft this query in order to first craft that how this query actually works, I

18:16.220 --> 18:21.530
need to see that how it looks like and that's why I have added console.log request to query.

18:21.530 --> 18:25.640
So I'm going to go ahead and copy everything from slash product to everything.

18:25.640 --> 18:30.650
So I'm going to go ahead and save this one and I'm going to put a comment on this one as well.

18:31.490 --> 18:33.230
And let's go on up here.

18:33.650 --> 18:37.970
And when I was testing this test product, I actually added up a lot of code and stuff.

18:37.970 --> 18:41.090
So this is exactly what I tried before.

18:41.090 --> 18:42.530
Actually, I showed it to you.

18:42.530 --> 18:44.090
So this is what I was trying.

18:44.090 --> 18:45.110
Okay, moving on.

18:45.110 --> 18:49.220
So if I go ahead and paste this one again, I need to remove another slash.

18:49.220 --> 18:51.890
So this is the same query product question mark and all of that.

18:51.890 --> 18:55.520
And notice here in the params, they are also saying all these things that you are looking for.

18:55.520 --> 19:03.080
So gTLD ratings category and again remember this G20 always put on the fields which are actually numbers.

19:03.170 --> 19:06.290
Let's go ahead and send this and see what happens.

19:06.980 --> 19:10.790
I go ahead and send this and this says, hey, this is.

19:11.960 --> 19:12.920
Test product.

19:13.460 --> 19:15.020
Why cannot I get it?

19:16.190 --> 19:16.760
Okay.

19:17.760 --> 19:19.440
It looks like it is.

19:19.620 --> 19:20.250
Yeah.

19:21.090 --> 19:22.770
Are we not getting it at all?

19:23.400 --> 19:25.710
Request dot query it as product should be there.

19:26.040 --> 19:28.710
Let's go ahead and try it one more time and send it.

19:29.490 --> 19:31.290
And says, Hi, I cannot get it.

19:31.290 --> 19:34.710
Let's see that this is a slash test product slash product.

19:34.750 --> 19:35.030
Okay.

19:35.040 --> 19:36.510
I don't need to send the product here.

19:36.510 --> 19:38.900
Actually, I can just go ahead and say.

19:38.910 --> 19:39.630
Question mark.

19:39.630 --> 19:41.220
So this was wrong.

19:41.220 --> 19:42.300
Let's send it again.

19:42.300 --> 19:42.930
And there we go.

19:42.930 --> 19:44.280
Finally, we have received this.

19:44.340 --> 19:49.350
Now, the important thing which I want you want your attention on this one is this part.

19:49.590 --> 19:54.810
Notice here it actually crafts the entire query into this syntax.

19:55.020 --> 19:57.990
So notice here it says search.

19:58.440 --> 20:02.000
And the search is coming up as a standalone object in itself.

20:02.010 --> 20:04.350
The page is coming up as a standalone object.

20:04.350 --> 20:06.310
The important part is this rating.

20:06.330 --> 20:10.410
Now, notice here the slash end is also coming up because I actually copy pasted the stuff from the

20:10.410 --> 20:10.830
browser.

20:10.830 --> 20:17.220
Usually it doesn't happen, but notice here I can actually go ahead and copy this and go back into the

20:17.220 --> 20:18.240
code part.

20:19.520 --> 20:20.660
Into this one.

20:21.390 --> 20:26.520
And for a moment, let's just uncomment this one and try to compare what we have received.

20:26.520 --> 20:31.440
So we have received something like this, which is rating and we actually don't have the slash.

20:31.440 --> 20:34.280
And also this was just from copying and pasting.

20:34.290 --> 20:41.130
Now can you see how much similarity is there that if I want to use this a user find, I can actually

20:41.130 --> 20:46.890
go ahead and inside this parenthesis, I can just create a bracket up here and can pass on this query,

20:46.890 --> 20:49.980
which would be instead of looking the quantity, it would be saying rating.

20:49.980 --> 20:51.270
There we go, nice and easy.

20:51.270 --> 20:53.790
And after that, we already got this parenthesis.

20:53.790 --> 20:57.960
And inside the parenthesis we are getting a GTI and that is equal to four.

20:57.990 --> 21:03.060
Now obviously this four is right now a string because it is coming from the URL and all these stuffs,

21:03.060 --> 21:08.310
but it will be automatically be converted or we can actually convert it into a purely number format.

21:08.340 --> 21:15.780
Importantly here is that I have now the knowledge to convert this GTI into the dollar GTI and that's

21:15.780 --> 21:17.640
all it takes to find the query up here.

21:17.640 --> 21:22.170
And we will be using this exact same logic and syntax that I walked you through in this video.

21:22.170 --> 21:26.400
So it is really important for you to understand that what we are trying to do and how we are actually

21:26.400 --> 21:27.030
doing it.

21:27.030 --> 21:32.400
So we are going to go ahead and take all the query and when we take all the query itself, we are going

21:32.400 --> 21:33.090
to work like that.

21:33.090 --> 21:37.020
Now again, there is a little bit more to it, a little bit more to it, not just only this.

21:37.200 --> 21:41.520
Now notice here this entirety of the thing is coming up as an object.

21:41.520 --> 21:45.600
Now, our replacement method actually works only on string.

21:45.600 --> 21:47.400
That is a string specific matter.

21:47.580 --> 21:55.110
And in order to further put this data into the find query itself, then we have to convert it back into

21:55.110 --> 21:56.040
an object.

21:56.040 --> 22:00.420
So please remember this always that whatever the data comes up is going to be string.

22:00.420 --> 22:03.180
String first needs to be converted into JSON.

22:03.180 --> 22:08.820
So JSON we can use the methods of parse and string, ify and all of that and we can work through that.

22:09.120 --> 22:14.040
I know this is a really long video, but this kind of video is really important because that's whole

22:14.130 --> 22:17.460
what we are focusing on to the entirety of the operation.

22:17.460 --> 22:22.410
So remember the steps we have already studied that entirety of the pagination search filter.

22:22.410 --> 22:26.700
This is all what we are taking in just one single string and this is the real use case.

22:26.700 --> 22:29.340
This is how you will be actually coding this stuff.

22:29.340 --> 22:30.960
So I hope you have understood this one.

22:30.960 --> 22:32.190
I know really long.

22:32.190 --> 22:35.880
So a little bit boring as well, but this is really important topic.

22:35.910 --> 22:39.450
In the next video, we are going to go ahead and continue to write our product controller.

22:39.450 --> 22:44.220
I'm going to go ahead and comment this part as well so that it remains with you as an exercise.

22:44.220 --> 22:50.310
And not only that, I will also give you a little bit of this URL as well, so that later on you can

22:50.310 --> 22:51.420
practice this stuff.

22:51.420 --> 22:53.340
So let me go ahead and add this one.

22:53.340 --> 22:57.270
So this one is actually your URL, just like that.

22:57.270 --> 22:58.980
And let's go ahead and comment this.

22:59.280 --> 23:01.590
And also let me give you further down the road.

23:01.590 --> 23:06.180
This example also, maybe you want to have some more code with that.

23:06.180 --> 23:08.850
So this is all again, this is all a test file.

23:08.880 --> 23:12.990
I won't be like giving you or something more onto this one.

23:12.990 --> 23:13.620
This is it.

23:14.580 --> 23:14.900
Okay.

23:15.120 --> 23:16.050
Yes, that's all.

23:16.170 --> 23:16.950
All about it.

23:16.950 --> 23:21.240
Let's go ahead and move on to the next video and finally continue our journey into the product model.

23:21.240 --> 23:23.100
Let's go ahead and catch up in the next one.
