Reputation: 47
I'm trying to add an array of questions to my schema. But it doesn't work. I got an empty array. Do I have to use several schemes?
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
}]
});
My callback questions: []
My data:
$scope.data = {
'seniority': $scope.answers.firstQuestion,
'secondQuestion': $scope.answers.secondQuestion,
'thirdQuestion': {
'Account': $scope.answers.thirdQuestionAccount,
'debitCard': $scope.answers.thirdQuestionDebitCard,
},
},
'fourthQuestion': $scope.answers.fourthQuestion,
};
Upvotes: 0
Views: 59
Reputation: 837
Check the docs. You have to specify the array as object.
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
}
});
Upvotes: 1