How to select specific field in nested populate in mogoose

前端 未结 2 1832
囚心锁ツ
囚心锁ツ 2021-02-04 06:02

here is my schema:

var UserSchema = new Schema({
    email: String,
    name: String,
    city: String,
    username: String,
    profilePic: String,
    phoneNo         


        
2条回答
  •  时光说笑
    2021-02-04 06:39

    try to do this:

    applicantListToExport: function (query, callback) {
      this
        .find(query).select({'advtId': 0})
        .populate({
          path: 'influId',
          model: 'influencer',
          select: { '_id': 1,'user':1},
          populate: {
           path: 'userid',
           model: 'User'
          }
        })
        .populate('campaignId',{'campaignTitle':1})
        .exec(callback);
      }
    

提交回复
热议问题