title: Automatically Populate Subdocuments After Saving
body: <p>I would like to always populate subdocuments after saving a particular Model <strong>automatically</strong>.  What I would really like is something like below:</p>
  
  <pre><code>MyModel.post('save', function(doc, next) {
      doc.populate('path').then(next);
  });
  </code></pre>
  
  <p>However, the above won't work because </p>
  
  <blockquote>
    <p><code>post</code> middleware do not directly receive flow control, e.g. no <code>next</code> or <code>done</code> callbacks are passed to it. <code>post</code> hooks are a way to register traditional event listeners for these methods.</p>
  </blockquote>
  
  <p>Of course, there are "Asynchronous Post Hooks", but they still do not receive control flow so there is no guarantee the subdocuments will be populated when I need it.</p>
  
  <p>Why not just use an embedded document?  For this case, the subdocuments are the same as the parent document (e.g. I'm using something like the Composite pattern), which would cause a circular dependency that I'm not certain how to resolve (or if I can even resolve it).  For other instances, I might want to be able to access the subdocuments without going through the parent document.</p>
  
  <p>Another approach I considered is something like:</p>
  
  <pre><code>const nativeSave = /* ? */;
  
  MyModel.methods.save = function save() {
      return nativeSave.call(this).then(function(savedDoc) {
          return savedDoc.populate('path');
      });
  };
  </code></pre>
  
  <p>However, there are two problems with this.  First of all, it seems a like a round-about solution.  If there is a more native approach that doesn't go against mongoose's implementation, I would prefer that.  Secondly, I don't know what I would set <code>nativeSave</code> to (as apparent by the <code>/* ? */</code>).</p>
  
  <p>So, what are some suggestions for getting this behavior?  If my second solution would be the best with the current version of mongoose, what should I set <code>nativeSave</code> to?  I've already considered embedded documents, so please don't suggest using them unless you are providing a suggestion about resolving the circular dependency.  Even then, I would like a solution for the other use-case I mentioned.</p>
  
  <p>As explained in my comment, this is not the same as manually populating a subdocument after saving as other posts have asked.  I want this to happen automatically to avoid leaking my implementation details (e.g. using ObjectIds instead of real documents).</p>