if i have this collection:
db.createCollection("misMensajes", {max: 100});
And documents with this distribution:
db.misMensajes.insert(
{
"FechaEnvío": new Date("2015-06-22"),
"Texto": "bla",
"Destinatarios":[
{
"Nombre": "Pepa",
"Edad": 15,
"Apodo": "P"
},
{
"Nombre": "Juan",
"Edad": 16,
"Apodo": "J"
}
]
}
);
What i want to do is a query to get the documents that have for "Destinatarios" "Edad" greater than 15 and less than 18. I don't know how to query "inside" the array "Destinatarios". I am starting in mongo and I don't understand many things. What I have until now is:
db.misMensajes.find({
$and:[
{Edad:{$gt:15}},
{Edad:{$lt:18}}
]
});
But this is not giving me what I need.