I\'m working on a query to find cities with most zips for each state:
db.zips.distinct(\"state\", db.zips.aggregate([ {$group:{_id:{state:\"$state\", city:\"
You can call $setUnion on a single array, which also filters dupes:
$setUnion
{ $project: {Package: 1, deps: {'$setUnion': '$deps.Package'}}}