in Education by
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)

1 Answer

0 votes
by
Finally, I've created the structure of my form-maker data. form.model: { title: { type: String, required: [true, 'Form must have a title'] }, owner: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: [true, 'Form must have a owner'] }, active: {type: Boolean, default: true}, deleted: {type: Boolean, default: false}, fields: [{ name: String, //that field id and must be auto generated and not be modified by end user label: String, type: Number, //1:Selective, 2:Descriptive, 3:Range required: Boolean, placeholder: String, selectable_items:[{ label: String, value: Number, selected: Boolean }], range:[{ min: Number, max: Number, step: Number, default: {type: Number, default: 0} }] }] } form.users.model: { form: { type: mongoose.Schema.Types.ObjectId, ref: 'Form', required: true }, users: [ { type: mongoose.Schema.Types.ObjectId, ref: 'User', role: Number //0:Admin, 1:Editor, 3:Viewer } ] } form.values.model: { form: { type: mongoose.Schema.Types.ObjectId, ref: 'Form', required: true }, values: [ { name: String, value: Object } ] }

Related questions

0 votes
    I am trying to add an if condition; Idea is If I enter the input as print or text with 4 in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am trying to add an if condition; Idea is If I enter the input as print or text with 4 in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am trying to add an if condition; Idea is If I enter the input as print or text with 4 in ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have working (stock) script from node var cluster = require('cluster'); var http = require(' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have yet another "Can't set headers after they are sent." problem. I've created a post router ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I am trying to write some stuff in a file using reactJS and nodeJs but it doesnt work. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am trying to write some stuff in a file using reactJS and nodeJs but it doesnt work. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Here is my data: { { "_id" : ObjectId("623a92139e19f99295167786"), "headline" : "headline1", " ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do here is use the 2 functions but I don't know how to use both of them ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do here is use the 2 functions but I don't know how to use both of them ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I'm getting unexpected results for getting the collections between two columns. I have this simple collection: ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm getting unexpected results for getting the collections between two columns. I have this simple collection: ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    The napi_create_date function appeared in Node.js starting with 11.11.0 version. https://nodejs.org/api/n- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Does server-side rendering with react-loadable work with Webpack 4 and Babel 7? I've been unable to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I'm trying to debug my nodejs app using node-inspector. But Google Chrome doesn't show the code. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
...