I'm trying to make a form-maker with Node.Js and MongoDB but confused about the data structure. By the way, I created a form.model to store the form structure:
{
title: {
type: String,
required: [true, 'Form must have a title']
},
users: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
role: Number
}],
owner: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true
},
active: {type: Boolean, default: true},
fields: [{
case_id: String,
label: String,
type: Number, //1:selective, 2:descriptive, 3:range
required: Boolean,
default: {
title: String,
value: Number,
},
placeholder: String,
items:[{
label: String,
value: Number,
}],
range:[{
min: Number,
max: Number,
step: Number,
default: {type: Number, default: 0}
}]
}]
}
and a form.data.model to store the data of forms:
{
form: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Form',
required: true
},
fields_data: {
"case_id": Object //value per case_id
}
}
Is that true? or there is the best practice for that? If I modify the form fields how control the data about?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)