Update Method
Last updated
Last updated
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.
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.
Configure the Query Method
In the left pane:
Change the Method to Update.
Update the Route Name if required.
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 :
This request is to update the last name of mary to "xxx"
Save the Endpoint
Click on the Save button in the bottom-left corner of the side pane.
Your update 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 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.
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.