Hello! Is this possible to store/save deleted data or rows from one table/sheet into another table? I am working with a spreadsheet as a resource. I want to apply soft delete on it that is if I delete something from my table, I want to remove it from the main table but want to store that deleted data into another table if that is possible. I would be very thankful if you guys can help.
I imagine there are a couple different ways you can do this. One is to keep track of the rows you have "deleted" using a temporary state, you can then filter those rows out of the original table and into the table of deleted rows.
There's a delete button column on the main table that adds a copy of the row to a
deleted_rows temp state:
Here they're inserted into the temp state with the
setIn function and
deleted_rows.value.length as the index so that they're always appended to the end of the array.
Those rows can then be filtered out of the main table using lodash's
_.isEqual functions in a transformer:
The value of
deleted_rows also gets passed to a separate table so that they can be displayed there:
The result looks like this:
This is only one way to do it though, curious if others might approach this differently
Just want to make another post here as it seems the initial question is asking for a table of deleted rows that exists in an external database and not as a temporary table within Retool in which case the above solution doesn't work.
If you'd like to store the deleted rows externally it's possible to have the delete button in the table trigger an insert query to the external database instead of inserting it into the tempstate. Then, have the delete query for your sheets resource run as a success handler on the external database query. (Here the
credits table is a placeholder for what would be your deleted rows table).\
Having the actual delete query run on success of the insert query should ensure that rows that aren't successfully added won't get accidentally deleted and be inaccessible.
Once you've set that up you can run a query that fetches data from the deleted rows table and pass it to a separate table component in order to view it within Retool.