Has anyone tried incorporating distinct
in their query using Spring Data for Mongo
. If you have an example can you please post it. Where and how sh
You can do it with the help of MongoOperations -
Query query = new Query(where("field").in(requestIds));
List result = mongoOperations.findDistinct(query, "fieldName", "collectionName", String.class);
With MongoTemplates -
mongoTemplate.getCollection("collectionName").distinct("filedName", requestIds);