How can i find object from an array in mongoose

Viewed 13682

I have a schema like following : -

var P = {
     s : [{
         data : [],
         sec : mongoose.Schema.Types.ObjectId
     }]
 };

Now I want to find only the object of section not entire the row. Like If I pass sec value I want only the value of s.data of that sec object.

example : -

{ s : [ 
    {
       data : [],
       sec : '52b9830cadaa9d273200000d'
    },{
        data : [],
       sec : '52b9830cadaa9d2732000005'
    }
  ]
}

Result should be look like -

 {
    data : [],
    sec : '52b9830cadaa9d2732000005'
 }

I do not want all entire row. Is it possible? If yes, then please help me.

3 Answers
Related