Skip to content

¿How can i create an object inside of an array? #6

@AlejandroJBArellano

Description

@AlejandroJBArellano

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions