Const mongoose = require(‘mongoose’)
Const Schema = mongoose.Schema
Const employeeSchema = new schema({
employeeName: {type: string},
job: [
{
reference:{ type: Schema.Types.ObjectId,
ref: "Job",
required: true},
joiningDate: {type: Date, default : Date.now},
lastDate: {type: Date}
}
]
})
Определение схемы работы - у вас могут быть и другие поля
Const jobSchema = new schema({
title:{ type:string},
income:{type:number}
})
module.exports = Job = mongoose.model("Job", jobSchema);