I'm new to mongoose and mongodb. I got problem when on doing my project. So i have to assign rating field in courses collection a value which is the average of rating field in reviews collection. This is the illustration:
Course({
_id: "1",
name: "math",
rating: (the average of rating group by course id);
})
Rating({
_id: "1",
rating: 5,
course_id: "1",
user_id: "1"
}, {
id: "2",
rating: 4,
course_id: "1",
user_id: "2"
})
Aucun commentaire:
Enregistrer un commentaire