Mongoose complex (async) virtuals

This is probably best handled as an instance method you add to teamSchema so that the caller can provide a callback to receive the async result:

teamSchema.methods.getSquad = function(callback) {
  Players.find({ team_id: this._id }, callback);
});

Leave a Comment