1
00:00:00,330 --> 00:00:05,850
And once we have the first two down, I think we already understand the pattern, so let's try to do

2
00:00:05,850 --> 00:00:11,460
the same thing with a name and we'll start with the most basic setup where essentially I'm going to

3
00:00:11,460 --> 00:00:18,660
go with a name and then whatever value I'm passing in, meaning in a query, and then eventually will

4
00:00:18,660 --> 00:00:22,170
come up with more complex setup where we have the regex.

5
00:00:22,170 --> 00:00:27,210
Because at the moment we need to understand that, of course, we have our most basic setup.

6
00:00:27,450 --> 00:00:31,950
We're only going to be looking for a product whose name matches.

7
00:00:31,950 --> 00:00:32,479
Exactly.

8
00:00:32,759 --> 00:00:34,050
Now, what am I talking about?

9
00:00:34,080 --> 00:00:36,270
Well, let me go back to the static one.

10
00:00:36,810 --> 00:00:38,130
Let me send it from here.

11
00:00:38,640 --> 00:00:43,460
And I just essentially want to get one of the names and I'll look for this one.

12
00:00:43,830 --> 00:00:50,370
And what you'll notice that with the most basic setup, affectively will get only the product whose

13
00:00:50,370 --> 00:00:51,600
name matches.

14
00:00:51,600 --> 00:00:52,150
Exactly.

15
00:00:52,410 --> 00:00:56,280
So if I go here and if I send, of course, now I get only one product.

16
00:00:56,280 --> 00:01:04,019
But if I mess that up here, meaning if I just pass in the first value, you'll notice that actually

17
00:01:04,019 --> 00:01:04,800
we get nothing.

18
00:01:05,190 --> 00:01:10,470
So, yes, it's a good starting point where the value needs to match.

19
00:01:10,470 --> 00:01:11,040
Exactly.

20
00:01:11,040 --> 00:01:17,340
But then of course will make it more complex and add rejects to the mix, because that way we'll be

21
00:01:17,340 --> 00:01:24,450
able to just pass in some kind of text values and we'll get the product where that value is somewhere

22
00:01:24,450 --> 00:01:25,020
in a name.

23
00:01:25,680 --> 00:01:31,410
So after my long rambling, let me just go back over here where we have get all product and what is

24
00:01:31,410 --> 00:01:32,900
the property that we're going to be looking for?

25
00:01:33,120 --> 00:01:34,730
Of course, that is the name.

26
00:01:35,010 --> 00:01:41,970
And there's also something that I want to mention where nothing stops you from setting up your own API

27
00:01:42,210 --> 00:01:49,410
and saying here that you're going to be looking for the search, for example, like they have in the

28
00:01:49,440 --> 00:01:50,660
hackers use API.

29
00:01:50,970 --> 00:01:51,930
Nothing stops you.

30
00:01:52,170 --> 00:01:54,720
It doesn't mean that these properties need to match.

31
00:01:54,720 --> 00:01:55,290
Exactly.

32
00:01:55,500 --> 00:02:00,840
Now, of course, I'm setting up this way because it's much more easier later when I'm setting up the

33
00:02:01,050 --> 00:02:02,100
object properties.

34
00:02:02,250 --> 00:02:06,480
So these ones definitely need to match whatever we have in a database.

35
00:02:06,840 --> 00:02:11,950
But as far as what values we're looking for from the query, this is really up to you.

36
00:02:12,210 --> 00:02:13,990
And again, just to showcase that.

37
00:02:14,010 --> 00:02:22,290
Notice how they in here use query so we can definitely set up our own API with a query or search or

38
00:02:22,290 --> 00:02:22,770
whatever.

39
00:02:23,010 --> 00:02:28,650
The only reason why I'm using the name is because it's just going to be easier when I'm setting up here

40
00:02:28,650 --> 00:02:29,460
in the object.

41
00:02:29,520 --> 00:02:30,720
Hopefully that is clear.

42
00:02:31,080 --> 00:02:37,380
And let's keep scrolling and start, like I said, with the most basic setup where I'll say if the name

43
00:02:37,380 --> 00:02:43,770
exists, then I want to go with my query object, of course, name property and that one will be equal

44
00:02:44,040 --> 00:02:44,810
to the name.

45
00:02:45,060 --> 00:02:51,060
So let me swing back to the postman again now switch to get all product.

46
00:02:51,480 --> 00:02:57,000
And since I'm just going to get one value since at the moment my name is going to match.

47
00:02:57,000 --> 00:02:57,570
Exactly.

48
00:02:57,780 --> 00:03:02,770
I'll remove these ones are featured and company and you're not.

49
00:03:02,770 --> 00:03:07,110
Let me go to complete project now where I can get the name right away.

50
00:03:07,440 --> 00:03:13,770
And once I have the name now of course I'm going to be looking for the product and we want to add a

51
00:03:13,770 --> 00:03:14,310
new key.

52
00:03:14,770 --> 00:03:19,110
And here I'll call this name and then I'm going to be looking for this value.

53
00:03:19,710 --> 00:03:23,940
And then once I send, of course, now I'll get that one product.

54
00:03:24,150 --> 00:03:28,770
And if we take a look at our query object course, this is what we have.

55
00:03:29,010 --> 00:03:30,120
So we have a name.

56
00:03:30,360 --> 00:03:37,380
And of course, whatever value I passed in, since I have one product that matches that, that's exactly

57
00:03:37,380 --> 00:03:37,910
what we get.

58
00:03:38,310 --> 00:03:45,970
But if you take a look at the Mongo's documentation, you'll notice that they have this query operators.

59
00:03:46,330 --> 00:03:53,010
Now, this one, when we use a little later when we set up our numeric filters, but with a name, I

60
00:03:53,010 --> 00:03:55,140
actually want to set it up as regex.

61
00:03:55,440 --> 00:04:01,710
And since Mongo's is sitting on top of Mungindi, B, we can get those query operators from the Mongo

62
00:04:01,710 --> 00:04:02,430
documentation.

63
00:04:02,790 --> 00:04:04,680
So let's search for Mongo.

64
00:04:04,680 --> 00:04:08,550
They be query operators, then let's navigate here.

65
00:04:08,760 --> 00:04:13,380
And as you can see, we have a long list of the operators.

66
00:04:13,590 --> 00:04:16,860
Now, the one that we're looking for is this one of the regex one.

67
00:04:17,050 --> 00:04:21,329
And essentially the setup is following where we go with regex.

68
00:04:21,600 --> 00:04:23,430
And then we have a bunch of options.

69
00:04:23,460 --> 00:04:27,450
Now, the one that we'll use is just case insensitive.

70
00:04:27,690 --> 00:04:31,080
And then, of course, we just need to pass in the pattern.

71
00:04:31,350 --> 00:04:34,800
So let me try it out back in our application.

72
00:04:35,160 --> 00:04:40,590
And I think I'm going to start with a static one just so I can show you the setup.

73
00:04:40,860 --> 00:04:43,860
And then, of course, we'll set up the more complex one as well.

74
00:04:44,250 --> 00:04:50,880
So let me go here and I'll scroll above where I have the static product and I'll just set up some kind

75
00:04:50,880 --> 00:04:51,290
of value.

76
00:04:51,420 --> 00:04:56,070
Now, since I'm not going to be passing this with a query, just understand that eventually, of course,

77
00:04:56,340 --> 00:04:58,310
the value will be coming from the query.

78
00:04:58,560 --> 00:04:59,850
So in here, I'm just going to say.

79
00:05:01,580 --> 00:05:09,590
Let's call a search and I'll just type A A now where I'm looking for a name instead of just passing

80
00:05:09,790 --> 00:05:13,280
in, the value directly will set it equal to an object.

81
00:05:13,610 --> 00:05:17,180
And then the setup is following where we go with dollar sign.

82
00:05:17,450 --> 00:05:21,170
And then I'm looking for a regex query operator.

83
00:05:21,350 --> 00:05:27,320
And then as far as the value of passing the search again, eventually it's going to be coming from our

84
00:05:27,320 --> 00:05:27,980
query here.

85
00:05:28,220 --> 00:05:33,380
And then I also want to set up the options and therefore I'm going to go with a dollar sign and then

86
00:05:33,380 --> 00:05:37,660
I'll pass in the options and I'll set options equal to I.

87
00:05:38,060 --> 00:05:38,690
And you're not.

88
00:05:38,690 --> 00:05:41,380
Instead of three years, why don't we go with just one?

89
00:05:41,690 --> 00:05:43,490
So let's have it over here again.

90
00:05:43,670 --> 00:05:50,350
The way it works, we're looking for nine property, but instead of looking for an entire name, instead

91
00:05:50,360 --> 00:05:56,150
we go with regex where essentially we're just looking for the pattern and the way we set it up, we

92
00:05:56,150 --> 00:05:58,010
go with regex operator.

93
00:05:58,250 --> 00:06:03,170
Then we pass in the variable, which of course, again, we're going to be coming from our square and

94
00:06:03,170 --> 00:06:09,460
then we have the options and in this case have passed an I, which just means for case insensitive.

95
00:06:09,710 --> 00:06:16,520
And once we navigate back to the postman and run it, you'll notice that, of course, I'll get all

96
00:06:16,520 --> 00:06:23,390
the items where there is at least a A and if we're going to go with a B now, of course, we're going

97
00:06:23,390 --> 00:06:25,040
to be getting a different value.

98
00:06:25,340 --> 00:06:32,150
Now, of course, I only have five now in order to set it up and get our product, what do we need to

99
00:06:32,150 --> 00:06:32,420
do?

100
00:06:32,580 --> 00:06:33,740
We need to look for name.

101
00:06:33,920 --> 00:06:34,940
We are doing that.

102
00:06:35,210 --> 00:06:41,810
And then where we have here, if name exists and then query object nine, we simply need to change this

103
00:06:41,820 --> 00:06:47,390
around where again, you want to go with this one instead and not speed this up.

104
00:06:47,400 --> 00:06:48,680
I'm just going to copy and paste.

105
00:06:49,040 --> 00:06:55,730
Let's scroll down and let's just say that if name exists then of course we'll use the rejections that

106
00:06:55,730 --> 00:06:58,970
now in this case, of course, the search doesn't exist.

107
00:06:58,970 --> 00:06:59,450
Correct.

108
00:06:59,780 --> 00:07:00,960
So we need to go in there.

109
00:07:00,960 --> 00:07:01,640
I'm sorry.

110
00:07:01,640 --> 00:07:06,890
If you need deposit here and write it from the scratch, please do so, because in my case, of course,

111
00:07:06,890 --> 00:07:10,840
I saved a little bit of time and just use the one from the stack.

112
00:07:11,060 --> 00:07:16,850
So once we save again, I'm purposely giving this one just check and see what is coming in.

113
00:07:17,060 --> 00:07:24,590
And if we hop back to all the product and of course now I'm just going to go with some kind of text

114
00:07:24,590 --> 00:07:28,400
value that is less than the entire time in this case.

115
00:07:28,400 --> 00:07:34,520
I'm going to go with E that I will look for a company and why don't we keep the same one over here?

116
00:07:35,090 --> 00:07:43,670
And I'll also look for features and files and notice how slowly but surely now we can search for more

117
00:07:43,670 --> 00:07:44,110
options.

118
00:07:44,360 --> 00:07:49,790
So in this case, I'm looking for feature set of company equal to IKEA.

119
00:07:50,060 --> 00:07:52,990
And then of course, in the name I'm looking for.

120
00:07:53,480 --> 00:07:56,480
So I'm looking for the product where E is in the name.

121
00:07:56,630 --> 00:08:04,130
And once I send check it out now of course I have six of them and if you'll double check, you'll notice

122
00:08:04,130 --> 00:08:05,840
that definitely is a name.

123
00:08:06,080 --> 00:08:13,280
The featured a set of false and of course company matches to the one that we have in a query string

124
00:08:13,280 --> 00:08:14,000
parameters.

