How to get child document from a collection in mondodb?
<p>I have created a collection which has sub collection data. I want to filter from sub collection with a key. </p>

<p>Here is my document:</p>

<pre><code>{
    "_id" : ObjectId("5758098356e3930537af15dd"),
    "manpower_data" : [ 
        {
            "_id" : ObjectId("5758098356e3930537af15de"),
            "created" : ISODate("2016-06-08T12:03:15.387Z"),            
            "designation" : "Visiting Evaluator",            
            "evaluatorContactNumber" : "987654321",            
            "evaluatorName" : "Dumy User1",
            "dealerCodeFor" : "ZSAE876",
            "region" : "Gurgaon"
        }, 
        {
            "_id" : ObjectId("5758098356e3930537af15de"),
            "created" : ISODate("2016-06-08T12:03:15.387Z"),            
            "designation" : "Resident Evaluator",            
            "evaluatorContactNumber" : "987654321",            
            "evaluatorName" : "Dumy User2",
            "dealerCodeFor" : "ZSAE877",
            "region" : "Delhi"
        }
    ]
}
</code></pre>

<p>When I run this query </p>

<p><code>db.mycollection.find({"manpower_data.dealerCodeFor":"ZSAE876"});</code> </p>

<p>It returns me all two sub document but I want to get only those <code>manpower data</code> which has matching <code>dealerCodeFor</code>.</p>