I am trying to write an aggregation to identify accounts that use multiple payment sources. Typical data would be.
{ account:\"abc\", vendor:\"amazon\", }
You can use sets
sets
db.test.aggregate([ {$group: { _id: "$account", uniqueVendors: {$addToSet: "$vendor"} }}, {$project: { _id: 1, vendorsCount: {$size: "$uniqueVendors"} }} ]);