我将评论模型定义为:
CommentSchema = new mongoose.Schema ({
name: String,
email: String,
website: String,
content: String,
createDate: Date,
updateDate: Date,
targetBlog: {type: mongoose.Schema.Types.ObjectId, ref: 'Blog'},
childrenComment: [{type: mongoose.Schema.Types.ObjectId, ref: 'Comment'}]
});
当我使用populate as:
Comment.find({targetBlog: blog._id}).populate({path: 'childrenComment'}).exec(function(err, comments) {
console.log(comments);
res.render('blog', { blog: blog, comments: comments});
});
我发现mongoose只填充一层深度。那么我怎么能让它填充多个级别,因为级别可以是2或3或更多。