3 ms·
I 100% agree `Undo` is the best way to go about this. Equally, I'm very curious to hear how others have implemented this in their app. The complexity for such a
by mbesto 13y ago
I 100% agree `Undo` is the best way to go about this. Equally, I'm very curious to hear how others have implemented this in their app. The complexity for such a small feature is actually quite high, because we start playing with the database (and therefore, in many cases a robust ORM)
Anyone have experience with doing something like this in Rails?
- ericingram 13y agoWe solve it using an "archive" collection in mongodb. Deleting moves a document from one collection to the archive, while undo moves it back. We also implement ability to find deleted documents by id, by searching the archive if the record is not found in the original collection. API looks like this: // delete something delete("/products/123") // see it in the archive get("/archive/products/123") // undelete it put("/products/123", {$restore: true})
- ForHackernews 13y agoOne simple implementation is just to queue up the action without committing it, then "undo" actually just cancels a pending action. The downside of this approach is "undo" becomes a limited time only offer.
- runner84111 13y agoActual deletion occurs on app close (or next open). The "delete" the user sees just hides the data.
- weavie 13y agoI just stick an isDeleted column on my tables. It does mean I have to remember to do a `where !isDeleted` on all my main queries, but apart from that the cost of undoing is incredibly cheap.