I can think of two ways to implement undo.
1. Use flags in the database, this method has its own drawback since the entry is not really deleted but flagged as one.
2. Client side. Delay the actual delete request to the server.
I can think of two ways to implement undo.
1. Use flags in the database, this method has its own drawback since the entry is not really deleted but flagged as one.
2. Client side. Delay the actual delete request to the server.
See this SO question for further detail and links: http://stackoverflow.com/questions/701131/data-structure-use...
Alternatively you could also have a very primitive form of version control : recycle-bin (edit: actually this is the same as point 1 =) )
- user X modified article Z
- user Y deleted article Z (revert?)
Note that I've only studied this in passing, and have never applied this in practice, so I can't answer just how effective this could be. Also not really sure how this works when other actions have already taken place, or how you can detect if an event cannot be recovered from (if there is such a thing)."Similarly, Joseph Gentle who is an ex Google Wave engineer and an author of the Share.JS library wrote: Unfortunately, implementing OT sucks. There's a million algorithms with different tradeoffs, mostly trapped in academic papers. The algorithms are really hard and time consuming to implement correctly. ... Wave took 2 years to write and if we rewrote it today, it would take almost as long to write a second time."
And if the user clicks UNDO, do a ROLLBACK?
Edit: Of course, if anything goes wrong before the COMMIT, you loose the transaction.
Database transaction are like try/except blocks - designed to clean up unexpected situations instantly, not as a state mechanism.