I'm creating a project management app using React, Node and MongoDB.I have created a project model (using Mongoose) with the following properties:const projectSchema = new mongoose.Schema({name: String,tables: {type: [],default: taskSchema,},deadline: Date,dateOfCreation:{type:Date,default:Date.now}});By default the tables property will be of the taskSchema type which consists of following properties:const taskSchema = new mongoose.Schema({name:String,assignedTo: [String],status: {type:Number,default:0},dueDate: Date,filesAttached: [String]});As one can see inside the projectSchema, I have defined a property tables which by default is of taskSchema type.I want to provide the user to add another table of some other schemaType like schoolSchema, which has properties like: numberOfStudents, services, activities etc..How do I specify the tables property of the projectSchema to have an array of different schemaTypes?Because the tables property can consist of both schoolSchema and taskSchema.How can I add multiple properties to a single field?
Submitted July 27, 2020 at 04:51PM by Vivek_Singh_Bisht
No comments:
Post a Comment