title: Push value to nested array object by mongoose
body: <p>I've got following code:</p>
  
  <pre><code>var query = {
      "lessons.teacher": req.user._id,
      "lessons.units.name": req.body.unitName
  };
  
  var projection = {
      $push: {
          "lessons.0.units.$.topics": {
              "name": req.body.topicName
          }
      }
  };
  
  Class.findOneAndUpdate(query, projection, function (err, class) {
      if (err) throw err;
  
      res.redirect('/topics');
  });
  </code></pre>
  
  <p>I'd like to push topic name to lesson.units.topic. When I stay with following push projection:</p>
  
  <pre><code>"lessons.0.units.$.topics": {
      "name": req.body.topicName
  }
  </code></pre>
  
  <p>It'll always add to first lessons array, however I'd like to push it to lessons array where following query meets requirement:</p>
  
  <pre><code>"lessons.units.name": req.body.unitName
  </code></pre>
  
  <p>Could you help me to understand what could I do to resolve that issue?
  I've tried by using following projection:</p>
  
  <pre><code>var projection = {
      $push: {
          "lessons.$.units.$.topics": {
              "name": req.body.topicName
          }
      }
  };
  </code></pre>
  
  <p>But I can't use more than one <code>$</code></p>