aggregate mongo get list of unique values that match code example Example: mongodb count distinct db.collection.distinct('field').length