title: mongoose conditional populate on subdocument
body: <p>i have a schema that looks like this:</p>
  
  <pre><code>var UserSchema = new Schema({
    name              : { type: String, required: true },
    email             : { type: String, lowercase: true },
    fences            : [{type: Schema.Types.ObjectId, ref: 'Group'}]
  });
  
  var GroupMemberSchema = new Schema({ 
      user  : { type: Schema.Types.ObjectId, ref: 'User', required: true },
    status  : { type: String, default : 'Invited' }
  });
  
  var GroupSchema = new Schema({
    name          : String,
    members       : [GroupMemberSchema],
    type          : String
  });
  </code></pre>
  
  <p>Group and User are exported as their own collections. I have an endpoint api/users/me in which I want to get my user and all my groups. Within the group I want to populate the users on my members. I have this working properly with this code:</p>
  
  <pre><code>User.findOne({
        _id: userId
      })
      .populate('groups')
      .exec(function(err, user) { 
        if (err) return next(err);
        if (!user) return res.json(401);
  
        var options = {
          path: 'groups.members.user',
          model: 'User'
        };
  
        User.populate(user, options, function (err, user) {
          return res.json(user);
        });
  
      });
  </code></pre>
  
  <p>However, I do not want to populate each member's associated user IF the group type == 'Special'. How would I put on the options do this?</p>