MongoDB differs with conditional in Java
Is it possible to implement MongoDB conditionally as described below, but with a Java driver?
db.orders.distinct( 'ord_dt', { price: { $gt: 10 } } )
I tried with MongoRepository
as below
// Enables the distinct flag for the query
List<Person> findDistinctPeopleByLastnameOrFirstname(String lastname, String firstname);
List<Person> findPeopleDistinctByLastnameOrFirstname(String lastname, String firstname);
But in my opinion it is not working correctly. I have also triedMongoTemplate
mongoTemplate.getCollection("mycollection").distinct("myfield")
But there is no way to implement the condition. Any idea how to solve this?
Regards
+3
source to share
2 answers