I have the following document :
{
"key": [
[
"FOO",
"BAR"
],
[
"FOO",
"BAZ"
]
]
}
I want to retrieve this document when at least one of the array from the key
array contains 100% of some values.
Exemples :
+--------------+----------------+
| Given values | Should Match ? |
+--------------+----------------+
| FOO | Yes |
| BAR | Yes |
| BAZ | Yes |
| FOO, BAR | Yes |
| FOO, BAZ | Yes |
| BAR, BAZ | No |
+--------------+----------------+
From the documentation, it looks like using the $elemMatch
and $all
operator could work, but it doesn't (the following returns nothing) :
{
"key": {
"$elemMatch": {
"$all": [
"FOO"
]
}
}
}
Playground : https://mongoplayground.net/p/BtqWjoUkASs
To summarize, I want to run the $all
operator on each of the arrays contained in an other array.