1
00:00:00,240 --> 00:00:00,720
Beautiful.

2
00:00:00,900 --> 00:00:02,310
We're done with our first step.

3
00:00:02,640 --> 00:00:07,050
We matched all the jobs that belong to certain user.

4
00:00:07,440 --> 00:00:10,650
Now we want to group them and we want to group them based on one.

5
00:00:11,070 --> 00:00:17,610
Well, on a status card because we have three options pending interview or cancelled.

6
00:00:18,270 --> 00:00:20,640
And then each of them, I want to count.

7
00:00:21,180 --> 00:00:23,950
So how many are there pending?

8
00:00:23,970 --> 00:00:25,350
How many are reconciled?

9
00:00:25,560 --> 00:00:32,369
And hopefully you see where I'm going with this and the way we'll do that, we'll go with group operators

10
00:00:32,369 --> 00:00:34,220
and now we're setting up our second step.

11
00:00:34,230 --> 00:00:35,520
And yes, that's the syntax.

12
00:00:35,820 --> 00:00:40,950
As you're setting up these steps in the aggregation pipeline, you need to go with comma and then add

13
00:00:40,950 --> 00:00:42,240
another object.

14
00:00:42,600 --> 00:00:44,190
So that's going to be our next step.

15
00:00:44,460 --> 00:00:48,990
Now we want to group them and effectively, this is what we're returning.

16
00:00:49,380 --> 00:00:55,640
So when you're looking at this object, this is what we'll get back right now in the stats.

17
00:00:56,010 --> 00:01:03,300
So unlike the match where we basically got all of the jobs now, get back the object with this underscore

18
00:01:03,300 --> 00:01:04,050
add property.

19
00:01:05,069 --> 00:01:09,780
And I will be equal to again, either pending interior or decline.

20
00:01:10,170 --> 00:01:13,800
And then how many of them are there?

21
00:01:14,040 --> 00:01:15,750
How many declined, how many interior?

22
00:01:16,020 --> 00:01:16,640
And all that.

23
00:01:16,650 --> 00:01:18,590
So let's try this one out.

24
00:01:18,830 --> 00:01:19,050
One.

25
00:01:19,060 --> 00:01:21,870
Go to jobs, comptroller one.

26
00:01:21,900 --> 00:01:23,250
Let's add that second step.

27
00:01:23,760 --> 00:01:25,920
I'll copy and paste just so can be the sample.

28
00:01:25,920 --> 00:01:29,310
But remember, the operator is group in this case.

29
00:01:29,850 --> 00:01:38,190
And as far as the turn we're looking for on the Score I.D. and then now will be equal to the stats property.

30
00:01:38,580 --> 00:01:45,360
So technically again, you can provide a different property, for example, you could go job that and

31
00:01:45,370 --> 00:01:47,580
that is going to count what kind of job types you're at.

32
00:01:47,580 --> 00:01:49,460
But in our case, that's not what we're looking for.

33
00:01:49,480 --> 00:01:50,340
We're looking for that.

34
00:01:50,640 --> 00:01:55,500
And then the syntax in this case is following where we go with quotation marks, one dollar sign and

35
00:01:55,500 --> 00:01:56,700
then we say status.

36
00:01:56,830 --> 00:01:59,760
Now we're accessing the spatters property value.

37
00:02:00,090 --> 00:02:01,340
None of let's go with comma.

38
00:02:02,400 --> 00:02:07,110
We're going to come up with another property that I'll place in the subject and that is going to be

39
00:02:07,110 --> 00:02:10,320
the count and that will be equal to another object.

40
00:02:10,320 --> 00:02:16,080
Again, this index comes from the MongoDB docks, where we go with another operator, which is some.

41
00:02:16,470 --> 00:02:18,180
And we set it equal to one.

42
00:02:18,960 --> 00:02:26,070
So once we save and then we navigate back to the stats one, what we should see right now is the array

43
00:02:26,250 --> 00:02:33,660
that we're getting back and notice how each option for the stats one is an object.

44
00:02:33,990 --> 00:02:36,510
It has this property of underscore Eddy.

45
00:02:36,840 --> 00:02:38,790
And I notice our nicely count.

46
00:02:39,660 --> 00:02:46,590
So we have 24 pending 24 decline and we have twenty seven in three years.

47
00:02:47,130 --> 00:02:51,750
So that's the first setup where we have the aggregation pipeline first.

48
00:02:52,730 --> 00:02:59,900
We grab the jobs that belong to a certain user and then we group them based on the status.

