title: Updating a Nested Array with MongoDB
body: <p>I am trying to update a value in the nested array but can't get it to work.</p>
  <p>My object is like this</p>
  <pre><code> {
      &quot;_id&quot;: {
          &quot;$oid&quot;: &quot;1&quot;
      },
      &quot;array1&quot;: [
          {
              &quot;_id&quot;: &quot;12&quot;,
              &quot;array2&quot;: [
                    {
                        &quot;_id&quot;: &quot;123&quot;,
                        &quot;answeredBy&quot;: [],   // need to push &quot;success&quot; 
                    },
                    {
                        &quot;_id&quot;: &quot;124&quot;,
                        &quot;answeredBy&quot;: [],
                    }
               ],
           }
       ]
   }
  </code></pre>
  <p>I need to push a value to &quot;answeredBy&quot; array.</p>
  <p>In the below example, I tried pushing &quot;success&quot; string to the &quot;answeredBy&quot; array of the &quot;123 _id&quot; object but it does not work.</p>
  <pre><code>callback = function(err,value){
       if(err){
           res.send(err);
       }else{
           res.send(value);
       }
  };
  conditions = {
      &quot;_id&quot;: 1,
      &quot;array1._id&quot;: 12,
      &quot;array2._id&quot;: 123
    };
  updates = {
     $push: {
       &quot;array2.$.answeredBy&quot;: &quot;success&quot;
     }
  };
  options = {
    upsert: true
  };
  Model.update(conditions, updates, options, callback);
  </code></pre>
  <p>I found this <a href="https://stackoverflow.com/questions/4121666/updating-nested-arrays-in-mongodb">link</a>, but its answer only says I should use object like structure instead of array's. This cannot be applied in my situation.  I really need my object to be nested in arrays</p>
  <p>It would be great if you can help me out here. I've been spending hours to figure this out.</p>
  <p>Thank you in advance!</p>