Delete row
There is no default functionality to delete a row from the database table. But we can use the Data+ API and a simple API call rule to get the same result.
-
Create an API entry on the Data+ Backend
(Make sure you have theDelete
operation enabled for the table) -
Add a
Button
column to your table and style it as required, here is an example:
-
Create a rule that triggers when the button is clicked and add the
API call
action:
-
Replace the following values:
- [dataplus.server] - is your Data+ Server address (remember the port if your server is self hosted)
- [table_name] - the actual database table name (should be equal to the one selected in the api entry)
- [api key] - copy it from the api entry
-
The body uses a rule value to determine the id that should be deleted
{"ids":["$(id)"]}
(
id
is the header name that contains the unique id of the row) -
For more information check out the API documentation
-
We probably want to reload the app after deleting the entry, simply add the reload action to the rule
-
Furthermore we could give the user some proper feedback, for example a notification or loading display until the reload is done