I try to match a document in this nested structure, it works for one level but not for the second level:
{
type:"example"
level1:[
{
name:"Bill"
level2:[
{
skill:"gardening"
},
{
skill:"carpentry"
}
]
},
{
name:"John"
level2:[
{
skill:"painting"
},
{
skill:"acrobatics"
}
]
}
]
}
I can match the first level array, for example:
db.collection.find({"level1.name":{$eq:"Bill"}})
But if for example I want to math the document with the skill field equal to "acrobatics" I do:
db.collection.find({"level1.level2.skill":{$eq:"acrobatics"}})
Does not work, any idea? (sorry if the naming of the example does not make much sense, but that's the structure that I'm facing).
Thank you!
$check this mongoplayground.net/p/1hl2l3CGKPb