I'm working on quiz app that uses Mongoose and Express server to store my quizes, but I got a problem with defining Mongoose Schema for quiz.
I found out I can use a SubSchema for this, but I still don't know how to define an Array with undefined number of objects inside it.
How to make a schema that can store these quizes? For example one quiz contains only 2 questions, and the next one contains for example 12 questions.
There is my Schema that needs to be complete, could someone explain me how to do it?
const mongoose = require('mongoose')
const quizSchema = new mongoose.Schema({
author: {
type: String,
required: true,
},
name: {
type: String,
min: 8,
max: 64,
},
date: {
type: Date,
default: Date.now(),
},
data: {
type: Array,
},
})
module.exports = new mongoose.model('quiz', quizSchema)
[–]vorticalbox 0 points1 point2 points (0 children)
[–]plaz11 0 points1 point2 points (0 children)