Search code examples
directus

Is it possible to hard delete a Directus item through the API or app?


Deleting an item from a collection, which has a status field, through the UI or API results in the item being soft deleted. However, in this one particular instance, we want to remove it from the database entirely.

If not possible, can it safely be done through the database by just deleting it from the table carrying the name of the collection? Any side-effects when doing it this way?


Solution

  • Found the answer on this page https://v8.docs.directus.io/guides/status.html#soft-delete:

    When deleting an item, the API does the following:
    
    Check if the collection has a status field
    Check if the delta data has the status field (meaning the status was changed)
    Check if the new status value (from delta data) has soft_delete = true
    If yes, it sets the action to SOFT_DELETE
    If no, it hard deletes the item (permanently removed from the database)