Mongoose: Populate a populated field Mongoose: Populate a populated field mongoose mongoose

Mongoose: Populate a populated field


From what I've checked in the documentation and from what I hear from you, this cannot be achieved, but you can populate the "uarticle.article" documents yourself in the callback function.

However I want to point out another aspect which I consider more important. You have documents in collection A which reference collection B, and in collection B's documents you have another reference to documents in collection C.

You are either doing this wrong (I'm referring to the database structure), or you should be using a relational database such as MySQL here. MongoDB's power relies in the fact you can embed more information in documents, thus having to make lesser queries (having your data in a single collection). While referencing something is ok, having a reference and then another reference doesn't seem like you're taking the full advantage of MongoDB here.

Perhaps you would like to share your situation and the database structure so we could help you out more.


You can use the mongoose-deep-populate plugin to do this. Usage:

User.find({}, function (err, users) {   User.deepPopulate(users, 'uarticle.article', function (err, users) {      // now each user document includes uarticle and each uarticle includes article   })})

Disclaimer: I'm the author of the plugin.


I faced the same problem,but after hours of efforts i find the solution.It can be without using any external plugin:)

    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);    }