0

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.

  • Also read this post: https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html And see https://stackoverflow.com/questions/30693785/how-to-write-denormalized-data-in-firebase for the most common options. If you're having trouble making this work, show what you've tried. Without that, it's unlikely that anyone can do a better job helping you than the documentation and blog posts on the topic. – Frank van Puffelen Dec 03 '17 at 23:29
  • That is everything I needed. Thank you. I will post answer the question when I have my code working. – Macaroni and not cheese Dec 04 '17 at 01:22

0 Answers0