Database

[{"_id":{"myId":"qwerty123","myType":"created","count":1}},{"_id":{"myId":"qwerty123","myType":"removed","count":3}},{"_id":{"myId":"qwerty123","myType":"updated","count":2}},{"_id":{"myId":"asd123","myType":"created","count":1}},{"_id":{"myId":"asd123","myType":"removed","count":2}}]

Query

db.collection.aggregate([{$group:{_id:"$_id.myId",myType:{$push:{$arrayToObject:[[{k:"$_id.myType",v:"$_id.count"}]]},},},},])

Result