I am using mongodb along with mongoose js in my node js application. I created a mongoose document schema called "CompanySchema" which uses TeamSchema (another mongoose document schema) as a supporting document. Inside this TeamSchema, it has an array defined as employees, which uses EmployeeSchema (another mongoose document) as a subdocument. So my question is when I try to save the CompanySchema document, the default value for the status of the unsatisfied requirement is not set. Can you guys explain to me what I'm doing wrong here?
export var EmployeeSchema = new Schema({
id: {
type: String
},
requirement: {
type: {
status: {
type: String,
enum: ['met' 'unmet'],
default : 'unmet'
}
},
default: null
},
});
export var TeamSchema = mongoose.model<TeamModel>("Team", new mongoose.Schema({
id: {
type: String,
},
name: {
type: String
},
employees: [EmployeeSchema]
}));
export var CompanySchema = mongoose.model<CompanyModel>("Company", new mongoose.Schema({
id: {
type: String
},
team: TeamSchema.schema,
}));