如何将一个数据插入一个集合(userModel)以及将同一数据插入到mongodb中的另一个集合(出勤)中。我能做什么?
一个集合userModel
let userSchema = mongoose.Schema({
'srId': { type: Number },
'empId': { type: String },
'empName': { type: String },
'designation': { type: String },
'blStartDate': { type: Date },
'startDateAtCompany': { type: Date },
'endDate': { type: Date },
'mobile': { type: String },
'panCard': { type: String },
'email': { type: String },
'dob': { type: Date },
'empContractSigned': { type: String },
'offerLetter': { type: String },
'empFormCsr': { type: String },
'originalSubmitted': { type: String },
'password': { type: String },
'otp': { type: String },
});
let userModel = mongoose.model('userModel', userSchema, 'userModel');
exports.userModel = userModel;
其他收集是出席
let AttendanceSchema = mongoose.Schema({
'mobile': { type: Schema.Types.mobile, ref: 'userModel' },
'time': [{
'inTime': { type: String },
'outTime': { type: String },
'totalTime': { type: String },
'syncTime': { type: Date, default: Date.now() }
}]
})
let Attendance = mongoose.model('Attendance', AttendanceSchema, 'Attendance');
exports.Attendance = Attendance;