0

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,

        };
0

1 Answer 1

1

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
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you were helpful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.