mongodb aggregation get document if value unique code example Example: mongodb distinct Db.collection.distinct('searchField')