1

I have this schema:

let answersSchema = new mongoose.Schema({
    answerId: {
        type: Number,
        required: true
    },
    answerTitle: {
        type: String,
        required: true
    }
});

let individualQuestionsSchema = new mongoose.Schema({
    questionId: {
        type: Number,
        required: true
    },
    type: {
        type: String,
        required: true
    },
    questionTitle: {
        type: String,
        required: true
    },
    answers: [answersSchema]
});


let questionSchema = new mongoose.Schema({
    questions: [individualQuestionsSchema]

});

And with mongoose I want to query all the data in my collection. When I execute :

QuestionMongo.findOne().exec((err, res) => {
                logger.debug(res);
        });

This is the output:

    { 
       _id: 5948eec705bb435feafb0d48,
       questions: 
       [ 
           { 
               questionId: 1,
               questionTitle: 'Question01',
               answerType: 'radio',
               answers: [Object] 
           },
           { 
               questionId: 2,
               questionTitle: 'Question02',
               answerType: 'radio',
               answers: [Object] 
           } 
        ] 
     }

Why is [Object] appearing instead of what it should display?

Pratyusha Terli
  • 2,343
  • 19
  • 31
amorotez
  • 33
  • 4

0 Answers0