I have the following firebase database: controle/roupas/tipo/docroupa. "Controle" is a collection, "roupas" a document that has another collection ("tipo") and finally "docroupa", a document that contains the keys and data I need. I want to create a condition that, when "docroupa" is successfully updated, I edit another document that is in the collection "controle", that being the document "log". This document will save the last modification on "docroupa", among other irrelevant data. The thing is, what should I do if I get an error on updating the "log" document? Do I have to manually undo the action on "docroupa"? What if this fails as well?
So what I want is a safe way for the data to update only if both savings succeed. I have read about denormalization here https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html but I did not completely understand it nor did I find any further explanation on the documentation. Thanks.