Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{match_id:1,players:[{cards:["c03","c15","c22"],result:1},{cards:["c01","c22","c23"],result:0}]}]
Query
db.collection.aggregate([{$unwind:"$players"},{$group:{_id:"$players.cards",count:{$sum:1}}}])
Result