Document:
User collection
{
'name': 'abc',
"watch" : [
{
"cat_name" : "Satish",
"cat_id" : "55ace5047f80b77017edsfa0e",
"script" : {
"script" : "SBIN",
"exchange" : "NS"
}
},
{
"cat_name" : "Satish",
"cat_id" : "55ace5047f8sdf7017ed8a0e",
"script" : {
"script" : "ITC",
"exchange" : "NS"
}
},
{
"cat_name" : "technotip",
"cat_id" : "55ace590htt0b77017ed8a10",
"script" : {
"script" : "SYNCOM",
"exchange" : "NS"
}
}
]
}
Now how can I fetch only the object cat_name = technotip
User.find({'name': 'abc'}, {});
This gets me the whole document. I only want the object which is inside key 'watch', with 'cat_name' as ''technotip'.
Please help.
If I had simple values inside the array I would have used
comparison operator to fetch the value, but in this case I have objects inside the array.