What is as is for the API explorer? When I delete a record, I know that it’s permanently deleted because I can add a new row with the same unique value.
Even if it’s a field that enforces no duplicates?
Correct, in Data Builder, on a table I created. I have a status title (String) and value (Int), and I set it to 1000, delete it, create another one with 1000, ad infinitum.
So I don’t understand what the change will do if it applies to all tables.
This feature doesn’t seem to be out yet because deleting records from the Data Builder still seems to soft delete. I can’t find a switch anywhere that lets me choose to hard delete instead, or to view soft deleted records and permanently delete them.
This is quite annoying, since I’ve already soft deleted records (without realizing it - I thought Delete meant truly deleting something) and now I can’t disallow duplicate values in my database because the soft deleted records have duplicate values.
Is there a way for me to use the API Explorer to view the records that have been soft deleted and then permanently delete them?
Hey Serena! We working on this right now. In our original attempt there were some edge cases that prevented us from pushing out the “original” solution. Sorry that it’s giving you trouble
Here is some info about some of the strategies we’re considering. Happy to recieve input on how you, and everyone else, would like to see this work.
SoftDelete vs HardDelete
(Strategy 1) - Table Level Settings
A table has a setting for Hard Delete Vs Soft Delete. At any point, the setting can be toggled on or off, however, changing the setting will result in irrecoverable data loss (destroy all deleted records).
We would restrict this to ONLY the Administrator role, as well as add some custom documentation about how the Administrator has specific special abilities… like destroying records.
If a table is set to soft delete, there will be a toggle in the Data Viewer that says “See Deleted Records”. ANY ONE THAT HAS ACCESS TO THE ADMIN DATA VIEWER WILL HAVE ACCESS TO DESTROYING RECORDS ON A SOFT DELETE TABLE. However, this functionality will NOT be available via the API, for now.
(Strategy 2) - Delete vs. Destroy Mutations
We add a recordDelete and recordDestroy mutation to the API. Delete soft deletes the record, Destroy eliminates the record. In the roles and permissions section, we add a drop down to the Delete action column instead of a checkbox with the following options.
Delete:
- Off
- Soft Delete
- Hard Delete
Anyone with the permission, app user or team member, will be able to manage records accordingly via the API.
There will be a toggle in the Data Viewer that says “See Deleted Records”. Only users with Hard Delete permission will see this toggle, and then be able to restore records. However, this functionality will NOT be available via the API, for now. Additionally, ANY MANDATORY RELATIONSHIPS WILL CASCADE THE DELETE/DESTROY OPERATION RUN ON THE PARENT WHEN THE FORCE FLAG IS SPECIFIED.
(Strategy 3) - Destroy flag
Add a mutation argument top the recordDelete operation that is false by default, though when true runs a destroy operation against the record and cascades to any mandatory relationships.
There will be a toggle in the Data Viewer that says “See Deleted Records”. Only Administrators with the table Delete permission will be able to view and hard delete records.
mutation {
somethingDelete(id: "123456789", destroy: true) {
success
}
}
I need this to be available via the API (and I imagine most others have the same requirement).
Strategies 2 and 3 are basically the same in my view, just a different mutation vs passing a flag.
So keen!
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
}
}
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)
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.
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:
- The admin interface made it clear you were performing a soft delete (and gave the ability to do a hard delete)
- There was a way to view soft-deleted records in the admin
- 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.
- We can certainly improve the error toasts.
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