mongodb get count of distinct values code example Example: mongodb count distinct db.collection.distinct('field').length