I'm using version 3.2.3. How do I get the function to return just a subdocument where cfmstatus == 'down'
rather than the whole document?
db.test1.insert({
_id: "host1",
"interfaces" : [
{
"inf": "ge-10/3/5",
"cfmstatus": "up"
},
{
"inf": "ge-7/1/2",
"cfmstatus": "down"
}
]
});
db.test1.find({
$where: function () {
for (var index in this.interfaces)
if (this.interfaces[index].cfmstatus == 'down')
return this;
}
});
Thanks in advance.