Need assistance with saving data in a mongodb
database such as the following:
{
name: "Just a name",
questions: [
{
question: "Question 1",
answerOptions: [
{id: 0, text: "answer 1"},
{id: 1, text: "answer 2"},
{id: 2, text: "answer 3"}
],
correctOptions: [ 0, 2 ]
},
{
question: "Question 2",
correctAnswers: [ "answer", "another answer" ]
}
]
}
Wondering if it's best to save all data in one collection or should consider decomposing and storing in separate related collections (main, answers, answeroptions, etc)?
If possible to consolidate in one collection, how would a Mongoose schema be structured? Specifically, describing objects and arrays of objects as fields in the Mongoose schema.
Thanks for any guidance!