I have a collection in MongoDB recording information about sport cards. Each document has values for the sport, manufacturer, brand and variation (see screengrab below). There are a number of cards associated with each variation.
I would like to write a query that provides one record for each combination of sport, manufacturer, brand and variation (ignoring that there are multiple cards for each variation). So I would end up with something like
Football, Upper Deck, Exquisite, Signature patch
Football, Upper Deck, Exquisite, Foursome Signature patch
Football, Upper Deck, some-other-brand, some-other-variation
Football, Topps, some-other-brand, some-other-variation
Baseball, Topps, some-other-brand, some-other-variation
I've tried a query such as:
db.checklists.aggregate([
{
$group:
{
_id:0,
manufacturer: {$addToSet: '$manufacturer'},
brand: {$addToSet: '$brand'},
variation: {$addToSet: '$variation'},
}}
]);
but it returns an empty array. Can anyone help?
Adding some images or errors I see when running the aggregation suggested in one of the answers below:

