Document in Mongo ->
{
emp_id : 11
proj_info :
[{
proj_id : 91
welcome to Stackoverflow, you can use ${project} method to reduce it to the scope of the subdocument and then you can use ${match}
there, like this:
collectionObject.aggregate([
{'$match':"emp_id":'11'}},
{'$project': {"proj_info": 1}},
{'$match':"proj_id":'91'}},
{'$project': {"proj_team": 1}},
{'$match': {"member_emp_id":'55'}}])
Thanks but still I had to make some changes as it was not giving expected output, I made these changes =>
collectionObject.aggregate([
{'$match':{'emp_id': '11', "proj_info.pro_id": '11' }},
{'$unwind': "$proj_info"},
{'$match': {"proj_info.proj_team.member_emp_id": '55' }},
{'$unwind': "$proj_info.proj_team"},
{'$project': {"proj_info.proj_team": 1,"_id" : 0}}
]):
and this worked for me.
Thanks for the help.