How do you get the number of Debit and Credit transactions? One way to do it is by using count() function as below.
But what if you do not know the possible values of cr_dr upfront. Here Aggregation framework comes to play. See the below Aggregate query
And the result is