Hi. I want my form POST something like this
`answersSchema = new Schema({
answer: String,
correct: Boolean
}),
questionsSchema = new Schema({
question: {
type: String,
required: "The questions are required, hacker."
},
answers: [answersSchema]
}),
examSchema = new Schema({
title: {
type: String,
required: true
},
author: {
type: Schema.ObjectId,
ref: "User",
required: The author is required.
},
questions: [questionsSchema],
usersDone: [{
type: Schema.ObjectId,
ref: "User",
}]
}, {
timestamps: true,
});`
When i put the name="answers.answer" it creates me an object with the array name: [], I understand why, but how can i do on the other way?
Hi. I want my form POST something like this
`answersSchema = new Schema({
answer: String,
correct: Boolean
}),
questionsSchema = new Schema({
question: {
type: String,
required: "The questions are required, hacker."
},
answers: [answersSchema]
}),
examSchema = new Schema({
title: {
type: String,
required: true
},
author: {
type: Schema.ObjectId,
ref: "User",
required:
The author is required.},
questions: [questionsSchema],
usersDone: [{
type: Schema.ObjectId,
ref: "User",
}]
}, {
timestamps: true,
});`
When i put the name="answers.answer" it creates me an object with the array name: [], I understand why, but how can i do on the other way?