MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Interrogazione di documenti incorporati nidificati con Mongoose

La popolazione profonda è stata aggiunta in Mongoose 3.6. https://github.com/LearnBoost/mongoose/issues/1377#issuecomment -15911192

Per il tuo esempio, sarebbe qualcosa del tipo:

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