title: Mongoose MongoDB: updating objects in a nested array
body: <p>I've got the following schema</p>
  
  <pre><code>var UserSchema = new Schema({
    emp_no: Number,
    skills: [{
      skill: {
        type: Schema.Types.ObjectId,
        ref: 'Skill'
      },
      startDate: {type: Date},
    }]
  });
  </code></pre>
  
  <p>I'm then trying to update the startDate of one particular skill. I've tried several differents ways, one of them being:</p>
  
  <pre><code>User.findOne({emp_no: req.body.emp_no}, function (err, user) {
      user.update( {'skills._id': 123}, {'$set': {
          'skills.$.startDate': req.body.startDate          
      }}
  }
  </code></pre>
  
  <p>This particular code gives:  err: 'cannot use the part (skills of skills._id) to traverse the element  </p>
  
  <p>The actual object looks like </p>
  
  <pre><code>{
  "_id" : ObjectId("5469753de27a7c082203fd0a"),
  "emp_no" : 123,
  "skills" : [ 
      {
          "skill" : ObjectId("547d5f3021d99d302079446d"),
          "startDate" : ISODate("2014-12-02T06:43:27.763Z")
          "_id" : ObjectId("547d5f8f21d99d3020794472")
      }
  ],
  "__v" : 108
  </code></pre>
  
  <p>}</p>
  
  <p>Any ideas what I'm doing wrong?</p>