3
我有三種模式,程序(程序),層(層),報價(報價)。一個程序可以有多個層次,一個層次可以有多個要約。所以我的程序有一系列的層次,相應的一層可以有一系列的優惠。現在我試圖填充程序如下:Mongoose中的多級人員不起作用
var Program = mongoose.model('Program');
var Offer = mongoose.model('Offer');
var Tier = mongoose.model('Tier');
Program.findOne({
_id: p_id
}).populate('tiers').exec(function(err, docs){
var opts = {
path: 'tiers.offers'
}
Program.populate(docs, opts, function(err, docs){
console.log('populated');
// var s = require('util').inspect(docs, {depth : null})
console.log(docs);
console.log(docs.tiers[0]); //Printing complete tier information
console.log(docs.tiers[0].offers[0]) //Just printing Object ID, not taking data from offers table
})
})
問題是它只是填充層而不是提供。我如何更深入?相應的例子是在這裏:
此行'.populate({path:'songMixs songArtist'})'確實幫助我理解了如何一次填充2條路徑......非常感謝! – natureminded 2017-11-14 02:35:17