title: Storing multiselect form values in Mongo with Mongoose
body: <p>Can't figure out what I'm doing wrong here. Below is my code which doesn't store anything into foods.ingredients array. Other fields (name, category) are stored correctly.</p>
  
  <p><strong>Schema:</strong></p>
  
  <pre><code>var UserSchema = new mongoose.Schema ({
      username: String,
      password: String,
      email: String,
      foods: [{
        name: String,
        category: String,
        ingredients: [String]
      }], 
      ingredients: [{
        name: String,
        category: String
      }]  
  });
  </code></pre>
  
  <p><strong>HTML form:</strong></p>
  
  <pre><code>&lt;form action="http://localhost:3000/api/foods" method="post"&gt;
    Name
    &lt;input type="text" name="name" /&gt;
    &lt;br /&gt;
    Category
    &lt;select name="category"&gt;
      &lt;option value="meat"&gt;meat&lt;/option&gt;
      &lt;option value="pasta"&gt;pasta&lt;/option&gt;
      &lt;option value="soup"&gt;soup&lt;/option&gt;
    &lt;/select&gt;
    &lt;br /&gt;
    Ingredients
    &lt;select multiple name="ingredients[]"&gt;
      &lt;option value="beef meat"&gt;beef meat&lt;/option&gt;
      &lt;option value="potatoes"&gt;potatoes&lt;/option&gt;
      &lt;option value="onion"&gt;onion&lt;/option&gt;
    &lt;/select&gt;
    &lt;br /&gt;
    &lt;input type="submit" name="submit" id="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>api.js:</strong></p>
  
  <pre><code>var search = { 'username': "tester"};
  var update = {
    $addToSet: {
      foods: {
        name: req.body.name, 
        category: req.body.category, 
        ingredients: { $each: req.body.ingredients }
      }
    }
  }; 
  
  User.findOneAndUpdate(search, update, function(err, food){
      if(err) {
        console.log(err);
        res.end('There was an error saving food.');
      } else {
        res.end('Food saved successfully!');
      };  
    }); 
  </code></pre>