Beautiful.
We're done with our first step.
We matched all the jobs that belong to certain user.
Now we want to group them and we want to group them based on one.
Well, on a status card because we have three options pending interview or cancelled.
And then each of them, I want to count.
So how many are there pending?
How many are reconciled?
And hopefully you see where I'm going with this and the way we'll do that, we'll go with group operators
and now we're setting up our second step.
And yes, that's the syntax.
As you're setting up these steps in the aggregation pipeline, you need to go with comma and then add
another object.
So that's going to be our next step.
Now we want to group them and effectively, this is what we're returning.
So when you're looking at this object, this is what we'll get back right now in the stats.
So unlike the match where we basically got all of the jobs now, get back the object with this underscore
add property.
And I will be equal to again, either pending interior or decline.
And then how many of them are there?
How many declined, how many interior?
And all that.
So let's try this one out.
One.
Go to jobs, comptroller one.
Let's add that second step.
I'll copy and paste just so can be the sample.
But remember, the operator is group in this case.
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.
So technically again, you can provide a different property, for example, you could go job that and
that is going to count what kind of job types you're at.
But in our case, that's not what we're looking for.
We're looking for that.
And then the syntax in this case is following where we go with quotation marks, one dollar sign and
then we say status.
Now we're accessing the spatters property value.
None of let's go with comma.
We're going to come up with another property that I'll place in the subject and that is going to be
the count and that will be equal to another object.
Again, this index comes from the MongoDB docks, where we go with another operator, which is some.
And we set it equal to one.
So once we save and then we navigate back to the stats one, what we should see right now is the array
that we're getting back and notice how each option for the stats one is an object.
It has this property of underscore Eddy.
And I notice our nicely count.
So we have 24 pending 24 decline and we have twenty seven in three years.
So that's the first setup where we have the aggregation pipeline first.
We grab the jobs that belong to a certain user and then we group them based on the status.