实际上,GitHub Copilot 建议我在学生模式中我有这样的东西:
const studentSchema = mongoose.Schema({
studentFirstName : {type : String, required: true},
studentLastName : {type : String, required: true},
studentEmail : {type : String, required: true},
studentClass : {type : String},
studentAssignments : [{
assignmentId : {type : Schema.ObjectId, ref: 'Assignments'},
assignmentGrade : {type : String, enum : ["A","A-","B+","B","B-","C+","C","C-","D+","D","D-","F"]},
assignmentStatus : {type : String, enum : ["Not Started", "Started", "Submitted", "Returned"]},
assignmentRemarks : {type : String},
assignmentCompeletedDate : {type : Date},
}],
studentTestQuizzes : [{
testQuizId : {type : Schema.ObjectId, ref: 'TestQuizzes'},
testQuizGrade : {type : String, enum : ["A","A-","B+","B","B-","C+","C","C-","D+","D","D-","F"]},
testQuizStatus : {type : String, enum : ["Not Started", "Submitted", "Returned"]},
testQuizRemarks : {type : String},
testQuizCompletedDate : {type : Date},
}],
studentAnnouncements : [{
announcementId : {type : Schema.ObjectId, ref: 'Announcements'},
announcementStatus : {type : String, enum : ["Read", "Not Read"]},
}],
// we need a courseId to link the student to a course
}, { collection: 'Students' });
这应该可行。如果它不起作用或者我需要做更多的工作,我会更新这个线程。