chapter twenty five
25 Soft deletion
This chapter covers...
- What is soft-deletion and when is it useful?
- How to indicate that a resource is marked as deleted (but not actually removed from the system)
- Required modifications for standard methods for resources that support soft deletion
- How to undelete soft-deleted resources
- How to permanently remove (expunge) soft-deleted resources
- Managing referential integrity
As we learned in Chapter 8 (Standard methods), the standard Delete method has one goal: remove a resource from the API. However, in many scenarios this permanent removal of data (so called, "hard deletion") from the API is a bit too extreme. For the cases where we want the equivalent of our computer's "recycle bin", where a resource is marked as "deleted" but still recoverable in the case of a mistake, we need an alternative. In this pattern, we explore "soft deletion", where resources are hidden from view and behave in many ways as though they have been deleted, while still providing the ability to be "undeleted" and restored to full view.