title: Mongoose: how to insert a field/value into an existing subdocument
body: <p>I am having trouble understanding how new <code>field:value</code> <code>objects</code> are added to <code>mongo</code> databases.  </p>
  
  <p>Say I have the following <code>document</code>:</p>
  
  <pre><code>var people={'firstname': 'John','surname':'Smith',
  'favouritefood':[{'fruit':'apples','drink':'coffee'}]}
  </code></pre>
  
  <p>how do I add 'vegetable':'broccoli' to 'favourite food' so it looks like this:</p>
  
  <pre><code>{'firstname': 'John','surname':'Smith',
  'favouritefood':[{'fruit':'apples','drink':'coffee','vegetable':'broccoli'}]}
  </code></pre>
  
  <p>If I type:</p>
  
  <pre><code>people.findOneAndUpdate({'firstname':'John'},
  {$push {favouritefood: {vegetable:broccoli}}},
  {upsert:true})
  </code></pre>
  
  <p>it gives me this:</p>
  
  <pre><code>{'firstname': 'John','surname':'Smith',
  'favouritefood':[{'fruit':'apples','drink':'coffee'},{'vegetable':'broccoli'}]}
  </code></pre>
  
  <p>and if I try:</p>
  
  <pre><code>people.findOneAndUpdate({'favoritefood':'apples'},
  {$push {vegetable:broccoli}}},
  {upsert:true})
  </code></pre>
  
  <p>it says:</p>
  
  <pre><code>'$push' is empty. You must specify a field like so: {$push: {&lt;field&gt;: ...}}
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>