Insert/Upsert Method
Last updated
Last updated
The Insert method in QueryDeck allows you to add new records to your database. The Upsert method is a combination of "update" and "insert," allowing you to either insert a new record or update an existing one if a conflict occurs. This ensures data consistency and prevents duplicate entries when using unique constraints.
With QueryDeck’s Insert/Upsert method, you can:
Add new records to your database.
Handle conflicts using the on_conflict
clause.
Update records if they already exist based on specified constraints.
From the left pane in the demo app, choose a base table to use. For this example, we will use the customers
table.
In the left pane:
Change the Method to Insert
or Upsert
.
Update the Route Name if required.
Click on the Save button at the bottom of the left pane.
Your endpoint for Insert/Upsert
is now ready.
Copy the endpoint URL by clicking it in the top right corner
Open Postman:
Paste the endpoint URL into the input field.
Change the request method to POST
.
Under the Body tab in Postman:
Select raw as the body type.
Paste a sample request body in JSON format. For example:
Click on the Send button in Postman.
You will receive a response indicating that the query was successful.
You have now successfully created and tested your Insert/Upsert
query.