Querydeck Docs
  • 👋Welcome to Query Deck
  • Getting Started
    • 😃Get Started With QueryDeck
      • Quickstart With QueryDeck
    • How It Works?
  • REST
    • Select Method
      • Joins
      • Sorting
        • Ascending/ Descending ordering
        • Dynamic Sorting
      • Filter
        • Dynamic Filtering
        • Groups
        • Exists clause
      • Pagination
        • Offset
        • Limit
    • Insert/Upsert Method
      • Nested Inserts (Joins)
      • Conflicting Columns
    • Update Method
      • Filters
    • Delete Method
    • Authentication
    • Authorization
    • Select by Id
  • GraphQL
    • Introduction to GraphQL in QueryDeck
    • Enabling GraphQL for Columns in QueryDeck
  • Testing Endpoints
Powered by GitBook
On this page
  • Overview
  • Using the Delete Method
  • Testing
  • Precautions
  1. REST

Delete Method

PreviousFiltersNextAuthentication

Last updated 2 months ago

Overview

The Delete method allows you to remove rows from a table based on specified conditions.

Using the Delete Method

1. Select the Base Table

  • 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.

3. Define Deletion Conditions

  • 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.

4. Save the Endpoint

  • Click on the Save button in the bottom-left corner.

  • Your delete query endpoint is now ready.

Testing

  • 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

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.

Send the Request

  • 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.


Precautions

  1. Test Your Query:

    • Always test your Delete query on a non-production environment to ensure that the filters work as intended.

  2. Use Filters:

    • Avoid running conditionless Delete queries to prevent accidental removal of all rows.

  3. 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!