I want to retrieve a single object from a nested array of an object in mongoose. I have attached sample json code below.
{
"_id" : ObjectId("1"),
"name" : "xxx",
"votes" : [
{
"actionType" : 11,
"voter" : [
{
"user" : "john",
"pass" : a
},
{
"user" : "david",
"pass" : b
}
]
},
{
"actionType" : 22,
"voter" : [
{
"user" : "john",
"pass" : c
},
{
"user" : "david",
"pass" : d
}
]
}
]
}
Expected result as
{
"user":"john",
"pass":c
}
Explanation: I want user object where actionType=22 and user=john