【发布时间】:2015-09-29 15:03:54
【问题描述】:
使用猫鼬,我想在我的主文档的子文档数组中填充一个属性。这是一个例子:
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 }],
});
如何从 User 中填充 typeQuestion,谁能告诉我怎么做?
【问题讨论】: