Skip to content
Advertisement

Is there such a query for mongodb?

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:

JavaScript

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.

JavaScript

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?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement