My app will use MongoDB as a database and Firebase Storage for storing images (although the question is actually general to any 2 different databases used in the same app).
I'm looking for the correct way to ensure that CRUD operations always fully success or fully fail (never half a change).
For example: A user uploads a post. this post has both data and images. I need to first insert the data to MongoDB, and then upload the images to Firebase Storage. If inserting the data to MongoDB fails, it's easy to make sure the code doesn't continue to upload the images. However, what if the data insert succeeds and the image upload fails? Even if I write code that makes sure the data from MongoDB is deleted if the image upload fails, it could fail as well, and the post will be uploaded with no images.
Is there any "built in" easy solution to this problem?