使用Mongoose时, 我想在User里populate一个对象数组字段里的一个属性q
var Question = new Schema({
title: {type: String},
answers: Schema.Types.Mixed, //{A:'',B:''}
category: {type: String},
type: {type: String},
enable: {type: Boolean, default: true},
sex: Number,
//random: {type: Number, default: Math.random},
createdAt: {type: Date, default: Date.now}
});
var User = new Schema({
username: {type: String},
password: {type: String},
typeQuestion: [{q: {type: Schema.Types.ObjectId, ref: 'Question'}, a: String,option:String }],
});
有人知道怎么实现吗
问题已解决
http://stackoverflow.com/questions/32834572/mongoose-populate-a-filed-in-a-subdocument-array