title: Find index of sub document in array of object
body: <p>I am developing a application in Node.js with use of mongodb and mongoose. I want to get the index of object from array of object returned by mongoose the data is given below, how can I get the index from details Array where record contains particular id like </p>
  
  <blockquote>
    <p>_id: 5334032ad1c4d2d616ad3a47</p>
  </blockquote>
  
  <p>The actual problem is that I am rendering a page which shows data of single nested record of details record, the id of that record is contained in my url like this </p>
  
  <blockquote>
    <p><code>http://localhost:3000/id-of-parent-course/id-of-nested-doc-in-details</code></p>
  </blockquote>
  
  <p>I am passing all the data to that page because I want to access the total count of details record, may be my way of doing this is wrong you can correct me with answer</p>
  
  <pre><code>course: 
     { __v: 1,
       _id: 5334032ad1c4d2d616ad3a46,
       updatedAt: Fri Mar 28 2014 13:14:07 GMT+0530 (IST),
       createdAt: Thu Mar 27 2014 16:23:30 GMT+0530 (IST),
       comments: [],
       details: 
        [ { status: 'Core',
            course_type: 'New',
            _id: 5334032ad1c4d2d616ad3a47,
            books: [Object],
            course_content: [Object],
            learning_outcomes: [Object],
            objectives: [Object],
            senate_approval_on: Fri Mar 14 2014 00:00:00 GMT+0530 (IST),
            ac_approval_on: Wed Mar 19 2014 00:00:00 GMT+0530 (IST),
            center_approval_on: Wed Mar 12 2014 00:00:00 GMT+0530 (IST),
            focus_group_approval_on: Tue Mar 11 2014 00:00:00 GMT+0530 (IST),
            effect_from: Tue Apr 01 2014 00:00:00 GMT+0530 (IST),
            pre_requisite: 'Javascript',
            offered_for: 'B.Tech',
            structure: [Object],
            department: 'ICT',
            course_no: 12345,
            title: 'Course 1' },
          { status: 'Core',
            course_type: 'New',
            _id: 533528472ad1706170b502b0,
            books: [Object],
            course_content: [Object],
            learning_outcomes: [Object],
            objectives: [Object],
            senate_approval_on: Fri Mar 14 2014 00:00:00 GMT+0530 (IST),
            ac_approval_on: Wed Mar 19 2014 00:00:00 GMT+0530 (IST),
            center_approval_on: Wed Mar 12 2014 00:00:00 GMT+0530 (IST),
            focus_group_approval_on: Tue Mar 11 2014 00:00:00 GMT+0530 (IST),
            effect_from: Tue Apr 01 2014 00:00:00 GMT+0530 (IST),
            pre_requisite: 'Javascript',
            offered_for: 'B.Tech',
            structure: [Object],
            department: 'ICT',
            course_no: 12345,
            title: 'Course 1' } ] } }
  </code></pre>