Reputation: 8622
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'},
I can populate creator
, but cannot populate comment
Posts
.findOne({ id: id })
.populate('creator')
.populate('comments')
.exec(function (err, post) {
});
Upvotes: 0
Views: 273
Reputation: 48566
Please try this one, with comments.id
as below
Posts
.findOne({ id: id })
.populate('creator')
.populate('comments.id')
.exec(function (err, post) {
});
Upvotes: 2