title: MongoDb array updating
body: <p>I am trying to update the following document in Mongodb.</p>
  
  <pre><code>    doc = { id : 10 , graph :[{userId:1,children:[2]},{userId:2,children:[]}]}
  
      db.test.insert(doc)
  </code></pre>
  
  <p>then I perform two updates:</p>
  
  <pre><code>db.test.update( {'id':10,'graph.userId' : 1}, { $push:{'graph.$.children':10}})
  
  db.test.update( {'id':10,'graph.userId' : 1},{ $push:{'graph':{'userId':10,'children':[]}}})
  </code></pre>
  
  <p>(Saddly :</p>
  
  <pre><code>db.test.update( {'id':10,'graph.userId' : 1},{ $push:{'graph.$.children':10},$push:{'graph':{'userId':10,'children':[]}}})
  </code></pre>
  
  <p>does not work)</p>
  
  <p>Is there a way to update these simultaneously ?</p>
  
  <p>Thanks a lot</p>