Delete Method
Last updated
Last updated
The Delete
method allows you to remove rows from a table based on specified conditions. Follow these steps to create and test a Delete
query in QueryDeck:
From the left pane in the demo app, choose the base table where you want to delete rows. For this example, we'll use the role_types
table.
2. Configure the Query Method
In the left pane:
Change the Method to Delete
.
Update the Route Name if required.
Add filters by clicking on the corresponding button on the side pane, to specify which rows should be deleted.
For example:
Delete all customers where roll_type_id
is :role_type_id
(as provided by the user in the URL)
These conditions will ensure that only the intended rows are removed.
Click on the Save button in the bottom-left corner.
Your delete query endpoint is now ready.
Copy the endpoint URL by clicking on Request.
Open Postman:
Paste the endpoint URL into the input field.
Change the request method to DELETE
.
add the required role_type_id at the end of the URL
6. Add a Sample Request Body (if applicable)
Under the Body tab in Postman:
Select raw as the body type.
Paste a sample request body in JSON format, specifying the filters for deletion. (Here we aren't doing this)
Note: If your API supports conditionless deletion (deleting all rows), ensure you proceed with caution and verify your intent.
Click on the Send button in Postman.
You will receive a response indicating the deletion status.
In this example, all rows in the role_types
table where role_type_id
is a38ea91f-b0d8-4ece-8fc3-701fbd8980c1 will be removed.
Test Your Query:
Always test your Delete
query on a non-production environment to ensure that the filters work as intended.
Use Filters:
Avoid running conditionless Delete
queries to prevent accidental removal of all rows.
Backup Your Data:
Ensure you have a backup of your data before executing Delete
queries in a production environment.
You have now successfully created and tested a Delete
query in QueryDeck. Continue exploring other methods to build robust API solutions!