25 Soft deletion

 

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.

25.1 Motivation

25.2 Overview

25.3 Implementation

25.3.1 Deleted designation

25.3.2 Modifying standard methods

25.3.3 Undeleting

25.3.4 Expunging

25.3.5 Expiration

25.3.6 Referential integrity

25.3.7 Effects on other methods

25.3.8 Adding soft delete across versions

25.3.9 Final API definition

25.4 Trade-offs

25.5 Exercises

Summary