I am trying to remove an array element from an array in a document using the method updateDoc, for that I need the document reference however I do not know how to get it as it was one generated by Firebase and the documentation or past questions have not helped. This is my code:
const subjectRef = collection(db, "users", auth.currentUser.uid, "subjects");
const querySnapshot = await getDocs(subjectRef);
subjects.forEach(subject => {
querySnapshot.forEach((doc) => {
if(doc.data().Subject == subject) {
const subject = doc.data();
const subjectName = subject.Subject;
const topics = subject.Topics;
//iterates through the topics of the subjects
globalTopicList.forEach(obj => {
topics.forEach(async topic => {
if(obj[1]==topic.id) {
const temp = {
Topic: topic.Topic,
Days: 0,
Rating: topic.Rating,
id: topic.id,
};
await updateDoc(docRef, {
Topics: arrayRemove(topic.id)
});
console.log('done');
}
});
});
}
});
});