I'm working in a Spring project and I need to search using different fields for example: id, username, city, country, company, phonenumber ...
It's obvious that I don't need to write a method like: studentRepository.findByIdAndUsernameAndCityAnd...
What I need exactly is the correspondent SQL query in MongoDB.
@Query("Select stu from Student stu
where (stu.entreprise.radical in ?6)
and (?1 is null or stu.status=?1)
and (?2 is null or stu.dateValidity=?2)
and (?3 is null or stu.montant=?3)
and (?4 is null or stu.devise=?4)
and (?5 is null or stu.referenceClient=?5)
order by stu.createdAt desc" )