title: How do i save a sub document's array in mongoose?
body: <p>I've seen a lot of examples, how to update an array, like this one
  <a href="https://stackoverflow.com/questions/26156687/mongoose-find-update-subdocument">Mongoose find/update subdocument</a>
  and this one
  <a href="https://stackoverflow.com/questions/15874750/partial-update-of-a-subdocument-with-nodejs-mongoose">Partial update of a subdocument with nodejs/mongoose</a></p>
  
  <p>but my objective is to update a specific field, for example in a Form, where user enters data.</p>
  
  <p>I'm using ejs for templating.</p>
  
  <p>Here's the code</p>
  
  <p>For clarity , here is User's Schema</p>
  
  <pre><code>var UserSchema = mongoose.Schema({
     resume: {
       education: [{ type: String}],
     }
  
  });
  </code></pre>
  
  <p>Routing code</p>
  
  <pre><code>router.post('/update-resume', function(req, res) {
      User.findById(req.user._id, function(err, foundUser) {
  
          // Take a look over here, how do I update an item in this array?
          if (req.body.education) foundUser.resume.education.push(req.body.education);
  
          foundUser.save(function(err) {
              if (err) return next(err);
              req.flash('message', 'Successfully update a resume');
              return res.redirect('/update-resume')
          });
      });
  
  });
  </code></pre>
  
  <p>If you take a look at the code above, my objective is to query a user data which is resume, and update its current value.</p>
  
  <p>Code for the front end</p>
  
  <pre><code>&lt;form role="form" method="post"&gt;
    &lt;div class="form-group"&gt;
      &lt;label for="education"&gt;Education:&lt;/label&gt;
      &lt;% for(var i = 0; i &lt; user.resume.education.length; i++) { %&gt;
      &lt;input type="text" class="form-control" name="education" id="education" value="&lt;%= user.resume.education[i] %&gt;"&gt;
      &lt;% } %&gt;
    &lt;/div&gt;
    &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Frontend code does work, it iterate in each <code>user.resume.education</code> array, and show all the values in the array. But how do I update it?</p>