I have an app based on FabricJS, storing the resulting drawing in JSON format in a file on a Linux server using a php backend.
I'd like to implement collaboration on the app so that several people can interact with the same drawing like Miro. This bit is easy enough- I'm intending to use websockets to broadcast little updates e.g. 'User 1 has moved object A to coordinates x,y' which are received and update the other clients.
What I'm wanting to know is an efficient way to store those changes in a persistent file in the backend. Currently the drawing is stored on a file on Linux, which is referenced by a database.
Any ideas?
Trivially I could just save the file every time the drawing is updated but that would be inefficient. Ideally I'd update the json on the backend when the updates happen, but can't work out how to just incrementally update a json file.