[FEATURE] Idea for hard delete vs. soft delete

Can you remind us what soft delete is used for again? The example you had of “inactive accounts” sounds very high-level, not something the database should be aware of. I think soft delete has caused more confusion than use. Who uses it and where is it used currently?

I even forget what triggers it. I create a new unique field and add data, then delete the row and create a new one with the same data, so I don’t see this “soft delete”. Was it something to do with mandatory?

Mike

Thanks for your response @sebastian.scholl. And sorry for my slow reply - I’ve been under the weather this week. I really do appreciate your getting back on this though.

I’m with @mike_ekim1024 in stepping back and asking if soft delete is a necessary feature. Is it a feature that is requested or taken advantage of? I find it more confusing than useful, and it seems (as others have suggested) that a database field with an active/inactive flag would much more easily fulfill the suggested use case than soft deletion would. Then, deletion would simply delete (permanently), which I think is the expected behavior.

If you are going to go forward with both soft and hard delete, then I’d lean toward Strategy 2/3. However, can you clarify the part where you say “Any mandatory relationships will cascade the delete/destroy operation run on the parent when the force flag is specified”?

I find the current feature very confusing. You don’t notice anything about soft delete if you check the No Duplicate Values flag when creating the field. You can add and delete as many times as you want with the same unique value. If you later check No Duplicate Values, then I see it. Why is there a difference, and is soft delete still happening in the former case, but the row is being re-used so it looks like a successful add?

TEST CASE:

  • Add a new table and name it “Test”
  • Add a field “title” of type Text
  • Set validation to Mandatory and No Duplicate Values
  • Click Create Field
  • Add a row with title “abc” and click Add Row
  • Select the row and click Delete selected records
  • Add a row with title “abc” and click Add Row

So far this works fine. Is the row being deleted, and recreated, or is it being re-used?

  • Go back to the schema editor and uncheck the No Duplicate Values flag on the title field
  • Click Save Field
  • Now turn it back on by checking No Duplicate Values and click Save Field
  • This results in an error saying:
    “The field ‘title’ has non uniques values. Please remove duplicate values and repeat the operation. Non unique values are: abc.”

I always check No Duplicate Values when creating fields and I know that there should be no duplicates, so I don’t encounter this problem. If records are soft deleted, how do you delete them currently, and who/what is using this feature currently? This also affects quotas (although I think it has been fixed). What if someone creates thousands of temporary rows. Currently they will live on as phantom rows taking disk space?

I know this is an old one, but we now have a working implementation! Here are some details below.


With the introduction of the new restore and destroy operations, we’re putting all the power in the hands of the developer. This allows a developer to do the following.

Delete a record (Soft delete - recoverable)

mutation {
  employeeDelete(data: {
    id: "ckdkkayio002b07la8uwmhi70"
  }) {
    success
  }
}
Restore a deleted record
mutation {
  employeeRestore(id: "ckdkkayio002b07la8uwmhi70") {
    name
  }
}
Destroy a record (Hard delete - permanent)
mutation {
  employeeDestroy(filter: {
    id: "ckdkkayio002b07la8uwmhi70"
  }) {
    success
  }
}
2 Likes

Is it possible to see soft deleted records in the data tab of the console? Would be great to hide them by default, but have a toggle or filter to show them (unless it’s already there but I missed it)

1 Like

Totally agree with @emroussel , I think in additional it would be great to being able to destroy multiple “soft” deleted records at once.

You didn’t miss it! We’ve only updated the API and are now added the UI management capabilities for Delete/Destroy.

2 Likes

Also wanted to hop in here and add that the current implementation is unclear. This is my first 8base project and I lost a decent chunk of time figuring out how to go in and actually destroy data when I needed to change the schema to validate uniqueness.

It’d be helpful if:

  1. The admin interface made it clear you were performing a soft delete (and gave the ability to do a hard delete)
  2. There was a way to view soft-deleted records in the admin
  3. The error message when trying to change validation didn’t disappear and linked to either documentation or the offending records.

Hey @bernsno - sorry to hear that. Couple of things.

1 & 2. You currently cannot Hard-delete records from the admin interface. All record deletes from the Admin interface are currently soft-deletes. Hard deletes (destroy) are done via the API.

  1. We can certainly improve the error toasts.

@sebastian.scholl

1 & 2. Yep, figured that one out after reading the comments. I just meant it’d be helpful in the admin interface to make that clear to users. Currently the action says delete which for a tool like this I would expect to be a hard delete.

I’m still unclear of the use cases for using soft-delete vs hard-delete. It sounds like a useful “layer” of functionality, but by using it you will still run into the No Duplicate Values issue.

Hey Mike, yeah you will still run into validation issues on soft delete, though now you can work around them by actually destroying the record.

I can’t see any “see deleted data” option in my admin panel, do I have to configure something or I’m I missing the option?
It would be cool if I could see the data that I have deleted from my tables.
Actually how can I see the data that I have deleted in my tables from my API?, can’t find any query that can do something like that

Hello @jetixsolorzano!

You can check the answers here:

Lada Kokotova | Technical Support Engineer