this is my code:
exports.updateCourseName = functions.firestore
.document('courses/{courseId}')
.onUpdate((change, context) => {
const newValue = change.after.data().name;
const previousValue = change.before.data().name;
const course1Id = context.params.courseId;
if(newValue != previousValue){
console.log("veränderung!")
return admin.firestore().collection("sets").where("course.id", "==", course1Id)
.get()
.then((querySnapshot) => {
if (!querySnapshot.empty) {
querySnapshot.docs[0].course.update({name: newValue})
}
})
}
});
The code is running with the error: TypeError: Cannot read property 'update' of undefined
. But after i change the name in the "courses" ( here is the name "dergerat", the name doesnt change in the sets/{set_id}/course/name. I get the log "veränderung!" after changing the name so this part is working fine.
Is there some problem with the return part? Or what am I doing wrong?

