Posts

Showing posts from March, 2021

Get distinct value in MongDB

 db.the_collection_name.distinct('the_field_name')   To get count of distinct value var collection = "the_collection_name"; var field = "the_field_name"; db[collection].distinct(field).forEach(     function(value) {         print(field + ", " + value + ": " + db[collection].count({[field]: value}))     } )