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 Update Method
  • Testing
  1. REST

Update Method

PreviousConflicting ColumnsNextFilters

Last updated 2 months ago

Overview

The Update method in QueryDeck is used to modify existing records in your database. It allows you to update one or more rows by specifying conditions to match records and providing new values for the desired columns. This method ensures data integrity by enabling you to control which fields are updated and under what conditions.

With the Update method, you can:

  • Change specific fields in a record.

  • Apply filters to update only matching rows.

  • Perform batch updates by modifying multiple records at once.

This method is useful for keeping your data up-to-date and accurately reflecting real-time changes.

Using the Update Method

  1. Select the Base Table

From the left pane, choose the base table you want to update. For this example, we'll use the customers table.

  1. Configure the Query Method

In the left pane:

Change the Method to Update.

Update the Route Name if required.

  1. Define Update Conditions and Values in the Request

Add the fields you want to update along with their new values.

Define conditions (e.g., filters) to specify which rows should be updated. For instance:

Set active to 0 for customers with last_name as Smith.

for example :

{
    "customer": {
        "active": 1,
        "activebool": true,
        "address_id": 5,
        "create_date": "2006-02-14",
        "email": "mary.smith@sakilacustomer.org",
        "first_name": "Mary",
        "last_name": "xxx",
        "last_update": "2013-05-26 14:49:45",
        "store_id": 1
    }
}

This request is to update the last name of mary to "xxx"

  1. Save the Endpoint

Click on the Save button in the bottom-left corner of the side pane.

Your update 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 PUT.

Add a Sample Request Body

Under the Body tab in Postman:

  • Select "raw" as the body type.

  • Set the "Content-Type" to "application/json".

  • Provide the JSON payload in the request body.

Send the Request

  • Click on the Send button in Postman.

  • You will receive a response indicating that the update was successful.

You have now successfully created and tested your Update query.