mongodb distinct count with condition code example Example: mongodb count distinct db.collection.distinct('field').length