sql >> Base de Datos >  >> NoSQL >> MongoDB

Consulta de documentos incrustados anidados con Mongoose

Se agregó una población profunda en Mongoose 3.6. https://github.com/LearnBoost/mongoose/issues/1377#issuecomment -15911192

Para tu ejemplo, sería algo como:

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