Answers for "mongodb distinct with count"

4

mongodb count distinct

db.collection.distinct('field').length
Posted by: Guest on April-24-2020
0

mongodb distinct with count

var collection = "countries"; var field = "country"; 
db[collection].distinct(field).forEach(function(value){print(field + ", " + value + ": " + db[collection].count({[field]: value}))})
Posted by: Guest on April-25-2022

Code answers related to "mongodb distinct with count"

Browse Popular Code Answers by Language