How to implement atomicity in node js transactions

Viewed 139

I am working on an application in which client(android/reactjs) clicks a button and five operations takes place, let say,

  1. add a new field
  2. update the old field
  3. upload a photo
  4. upload some text
  5. delete some old fields.

Now sometimes due to network issue or any another issue only some operations takes place and db gets corrupted. So my question is how can I make all this transactions one i.e. atomic i.e. either all will complete or the done operations will be rollback. And where should I do this in client(reactjs/android) or in backend(nodejs) with API ? I thought of making an API on backend(since chances of backend goes down is rare) and keep the track of the operations done(statelessly like using arrays). If in any case transaction get stopped, roll back all the done operations. But I found this expensive and it not covers the risk of server error. Can you suggest how can I implement/design this ?

0 Answers
Related