how to get a count of unique values in collection mongodb code example Example: mongodb count distinct db.collection.distinct('field').length