I can't find any valubale informations about my problem, therefore my post here.
My service utilizes Spring Boot, Webflux and Mongodb. My client in React has a search box, you can search by multiple fields. Is there the possibility to use e.g. Search Criteria like:
Query query = new Query();
query.addCriteria(Criteria.where("name").is("Eric"));
if(condition){
query.addCriteria(Criteria.where("location").is("USA"));
}
List<User> users = mongoTemplate.find(query, User.class);
Maybe should I use e.g. Query DSL library?
So far I use reactive repository:
public interface OfferRepository extends ReactiveMongoRepository<Offer, String> {
@Query("{'properties': {'$in': ?0}}")
Flux<Offer> findByPropertiesIds(List<String> propertiesId);
but I have no idea how to cope with multiple search criteria (some of them can be optional).