For example, I have a transaction in my app that involves many related documents like checking out a cart (with 1 document per product) with a purchase document that references all those product documents.
In this transaction, user may optionally answer a survey/feedback per product if he/she has purchased them before. So that’s 1 document per feedback. I then log these activities in another document so their reference ids are saved in that document.
With all these documents, how do I safely create them? What if during the creation of product documents, an error occurred? Or when I create the feedback documents? How do I handle these errors and ensure my database’s integrity?