Hi I have 2 Firestore collections named
- products collection
- category collection
when creating a document in the products collection, it adds a field name category which we get from a document in the category collection. (Simply when making a product we have to choose a category name from the category collection).
So far I have implemented this successfully. But now my problem is when changing the name field in a category document (changing category name/title), it changes to the new name in the category document but stays the same in the product document (since not notifying the category name change to related product documents).
For changing the category name I use the following code
Future<void> updateCategory({Key? key,cid,name}) {
return categories
.doc(uid).collection('categoryList').doc(cid)
.update({'name': name})
.then((value) => print("Category Updated"))
.catchError((error) => print("Failed to update category: $error"));}
How can I update the category name field in product documents, when I change the category name from the category collection?