I am trying to write an aggregation to identify accounts that use multiple payment sources. Typical data would be.
{
account:\"abc\",
vendor:\"amazon\",
}
An example
db.collection.distinct("example.item").forEach( function(docs) {
print(docs + "==>>" + db.collection.count({"example.item":docs}))
});
To identify accounts that use multiple payment sources:
db.payment_collection.aggregate([ { $group: {"_id":"$account" , "number":{$sum:1}} }, { "$match": { "number": { "$gt": 1 } } } ])
This will work perfectly fine,