Mongo Playground
Stage by stage output:
Template:
bson single collection
bson multiple collections
mgodatagen
update
indexe
explain
Configuration
bson
mgodatagen
[{"status":"ONBOARD","count":1},{"status":"PENDING","count":1},]
Query
db.collection.aggregate([{$group:{_id:"$status",count:{$sum:1}}},{$project:{_id:0,status:"$_id",count:1}}])
Result