我试图在我的架构中添加一系列问题。但它不起作用。我有一个空数组。我必须使用几种方案吗?
var questionnaireSchema = new mongoose.Schema({
seniority: String,
questions: [{
secondQuestion: String,
thirdQuestion: Array,
fourthQuestion: String,
fifthQuestion: String,
sixthQuestion:String,
seventhQuestion: String,
eighthQuestion: String,
ninthQuestion:String,
tenthQuestion: String,
eleventhQuestion: String
}]
});
我的回调 问题:[]
我的数据:
$scope.data = {
'seniority': $scope.answers.firstQuestion,
'secondQuestion': $scope.answers.secondQuestion,
'thirdQuestion': {
'Account': $scope.answers.thirdQuestionAccount,
'debitCard': $scope.answers.thirdQuestionDebitCard,
},
},
'fourthQuestion': $scope.answers.fourthQuestion,
};
答案 0 :(得分:1)
检查docs。您必须将数组指定为对象。
var questionnaireSchema = new mongoose.Schema({
seniority: String,
questions: {
secondQuestion: String,
thirdQuestion: Array,
fourthQuestion: String,
fifthQuestion: String,
sixthQuestion:String,
seventhQuestion: String,
eighthQuestion: String,
ninthQuestion:String,
tenthQuestion: String,
eleventhQuestion: String
}
});