Tuesday 28 April 2020

Revert failed operations?

I have an endpoint that attempts to create/update a few documents in my DB (Mongo). Basically, its somewhat like this:Create an entityCreate another entityUpdate the first entity with the ID of the second entitySend 200Hypothetically speaking, something goes wrong and the second entity doesn't get created. So I send an error, and its all good, but now I am stuck with one stray entity. What would be the correct way to handle it? Potentially, I can just delete it but what if that hypothetical endpoint is creating / modifying more than just a handful of documents?Potentially, I could build some sort ofa system that "oversees" the whole process: if something happened say during Step 4, then revert/delete everything from Step 1 to Step 3, but it doesn't really sound like a good idea, does it?

Submitted April 29, 2020 at 01:05AM by pink_tshirt

No comments:

Post a Comment