This is how my function looks to edit a particular record
Future<void> updateCourse(Course updatedCourse) async {
QuerySnapshot courseQuery = await FirebaseFirestore.instance
.collection('Courses')
.where('title', isEqualTo: updatedCourse.title)
.get();
if (courseQuery.docs.isNotEmpty) {
DocumentSnapshot docSnapshot = courseQuery.docs.first;
final docId = docSnapshot.id;
await FirebaseFirestore.instance
.collection('Course')
.doc(docId)
.update({'title': 'This is Pratham'});
} else {
print("There is some problem");
}
}
I am not sure what is going wrong, but I keep on getting the error Some requested document was not found.
It will be very helpful if someone can help resolve this error. The if statement does run which means it is able to get that particular record. Not sure why I am not able to update it.