title: Mongoose complex (async) virtuals
body: <p>I have two <strong>mongoose schemas</strong> as follow:</p>
  
  <pre><code>var playerSchema = new mongoose.Schema({
      name: String,
      team_id: mongoose.Schema.Types.ObjectId
  });
  Players = mongoose.model('Players', playerSchema);
  
  var teamSchema = new mongoose.Schema({
      name: String
  });
  Teams = mongoose.model('Teams', teamSchema);
  </code></pre>
  
  <p>When I query Teams I would to get also the <strong>virtual generated squad</strong>:</p>
  
  <pre><code>Teams.find({}, function(err, teams) {
    JSON.stringify(teams); /* =&gt; [{
        name: 'team-1',
        squad: [{ name: 'player-1' } , ...]
      }, ...] */
  });
  </code></pre>
  
  <p>but I <strong>can't</strong> get this <strong>using virtuals</strong>, because I need an <strong>async</strong> call:</p>
  
  <pre><code>teamSchema.virtual('squad').get(function() {
    Players.find({ team_id: this._id }, function(err, players) {
      return players;
    });
  }); // =&gt; undefined
  </code></pre>
  
  <p>What is the best way to achieve this result?</p>
  
  <p>Thanks!</p>