I need to do a query on mongoDB due to I am developing in Java with Spring Boot and MongoDB. I know that this command is for arrays:
@Query("{ 'skills' : {$all : ?0}} ")
List<DataCV2> findAllSkillsInCV(ArrayList<String> skillsOfCV);
This query let me to find if all fields of the arraylist "skillsOfCV" are in the arraylist called "skills" However, I am trying to pass an arraylist as "skillsOfCV" to compare all the fields with a string field in database.
@Query("{ 'experienceCV' : {$all : ?0}} ")
List<DataCV2> findAllExperienceInCV(ArrayList<String> experienceOfCV);
The field "experienceCV" is a string one, and I want to compare if this string field contains all the fields of the arraylist "experienceOfCV".How could I do that?
CodePudding user response:
It is not possible to match String
and List<String>
using $all
in a straightforward way.
The best bet is that use String
field for the method and do the conversion programmatically.
Or else you can give a try with aggregation framework which has many useful aggregation operators.