This chapter covers
- Soft-deletion and when it is useful
- How to indicate that a resource is marked as deleted but not actually removed
- 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 7, the standard delete method has one goal: remove a resource from the API. However, in many scenarios this permanent removal of data (a 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.