Querying nested embedded documents with Mongoose Querying nested embedded documents with Mongoose mongoose mongoose

Querying nested embedded documents with Mongoose


Deep population was added in Mongoose 3.6. https://github.com/LearnBoost/mongoose/issues/1377#issuecomment-15911192

For your example, it would be something like:

Owner.find().populate('shelves').exec(PopulateBooks);function PopulateBooks(err, owners) {      if(err) throw err;      // Deep population is here      Book.populate(owners, { path: 'shelves.books' }).exec(callback);}


right now nested sub document population is not supported. i added a link to this post to the open github issue for future tracking.

https://github.com/LearnBoost/mongoose/issues/601