【发布时间】:2015-12-16 06:46:51
【问题描述】:
我将评论模型定义为:
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'}]
});
当我使用填充为:
Comment.find({targetBlog: blog._id}).populate({path: 'childrenComment'}).exec(function(err, comments) {
console.log(comments);
res.render('blog', { blog: blog, comments: comments});
});
我发现猫鼬只有一层深。那么我该怎么做才能让它填充一个以上的级别,因为级别可以是 2 或 3 或更多。
【问题讨论】:
标签: node.js mongodb express mongoose