0
var schema = new mongoose.Schema({
name: { type: String, require: true },
comments: [{
id: {type: Schema.Types.ObjectId, ref: 'Comment'},
vote: Number,
}],
creator: {type: Schema.Types.ObjectId, ref: 'User'},
我可以填充creator
,但不能填充comment
如何用其他字段在貓鼬中填充子文檔?
Posts
.findOne({ id: id })
.populate('creator')
.populate('comments')
.exec(function (err, post) {
});