title: How do update a specific field in mongoose?
body: <p>I have a data set which is</p>
  
  <pre><code>var JobSchema = Schema({
    candidates: [{
      user: { type: Schema.Types.ObjectId, ref: 'User'},
      status: { type: String, default: 'In Progress' },
    }]
  });
  </code></pre>
  
  <p>I want to find a specific <code>job's _id</code> and update a specific candidates' field such as <code>{ _id: 123, user: 12345, status: "In Progress" }</code></p>
  
  <p>The url for this operation is ---> <code>localhost:3000/apply/:job_id/user_id</code></p>
  
  <p>For example</p>
  
  <p>Let say that this is the current saved data in job mongodb </p>
  
  <pre><code>  { 
     "_id" : 123, ---&gt; job_id
  
     "candidates" : 
       [{ 
          "_id" : 234 , 
          "user": 345 , --&gt; user_id
          "status" : "In Progress" 
       }, 
  
         { 
          "_id" : 345 , 
          "user": 678 , --&gt; user_id
          "status" : "In Progress" 
        }]
      "__v" : 0 
    }
  </code></pre>
  
  <p>How do i update only a specific field let say <code>status</code> field that belong to a certain candidates' <code>_id</code> in mongodb, Here's my attempt</p>
  
  <pre><code>          Job.update(
                      {
                          _id: req.params.job_id,
                      },
                      {
                          $set: {'candidates.$.status': 'Accepted'} ,
                      }, function(err, count) {
                          if (err) return next(err);
                          callback(err, count);
                      });
  </code></pre>
  
  <p>I will get this error If I use the above operation.</p>
  
  <p>MongoError: The positional operator did not find the match needed from the query. Unexpanded update: candidates.$.status</p>