this is my collection structure :
coll{
id:...,
..,
fieldA:{
fieldA1:[
{
...
}
],
...,
fieldA2:[
{
text: "ciao",
},
{
text: "hello",
},
...
]
}
...
}
i want to find the document with for example text=”ciao”
I use the follow:
Db.coll.find({fieldA: { fieldA2: {$elementMatch:{ text:”ciao”} } } })
but the result is nothing…
how can I do to do this operation?
thank u very match..
You need to use dot notation to refer to the embedded document:
Also note that the operator is
$elemMatch, not $elementMatch.