有几种方法可以逐步解决
检索所有学生或特定学生的分数(检索分数数组中的特定元素)
Class.findOne({ name: 'Grade 5 - Section A'}) .populate('scores.studentId') .exec(function(err, class) { if (err) throw err; //now class.scores.studentId becomes ObjectStudent //hence you have all scores for all students});为特定主题添加/更新/删除特定学生的分数(在更新或删除的情况下,在scores [n]
.performance数组中检索特定元素;对于添加或添加到同一数组。
Class.findoneAndUpdate({name: 'Grade 5 - Section A' ,'scores.studentId': ObjectId('5776bd36ffc8227405d364d2') , 'scores.performance.subjectId' : ObjectId('577694ecbf6f3a781759c54a')} , {$set: {scores.performance. score: 50}} , function(err, data) {if (err) throw err });希望对您有所帮助



