I am using mongodb along with mongoose js in my node js application . I created a mongoose document schema called “CompanySchema” which is using “TeamSchema” (another mongoose document schema) as a sub document. Inside this “TeamSchema” it has an array defined as employees which is using “EmployeeSchema” (another mongoose document) as a subdocument. So my question is when I am trying to save the document “CompanySchema” the default value for requirement status “unmet” is not getting set. So can you guys explain me what I am doing wrong in 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,
}));
via Panduka Loc
No comments:
Post a Comment