Dittofi
Search…
Delete Event
An overview of how to configure your software application to delete records in one of your data models
The delete event allows you to delete a record in one of your data models. The delete event is used in most software applications, for example, in social media platforms such as Facebook or Linkedin, users are able to delete posts. Most platforms also include a "system settings" page where users can delete account. Whenever you want to give your users the ability to delete something, you will need to use the delete endpoint, action & event. In this tutorial we cover:
  • Setting up a DELETE endpoint
  • Linking our DELETE endpoint to an action
  • Deleting multiple records in our data model
For the purpose of this example, we will use a data model that holds different social media posts for different users.
Our goal is to set up a DELETE Endpoint that allows our users to delete data records in our data model whenever the endpoint is triggered.
There are two ways to do this, we can either:
  1. 1.
    Use the API Generator, see API Generator, OR
  2. 2.
    Build the endpoint, action & event from scratch.
In this article we will cover how to build the endpoint, action & event from scratch.

Setting up a DELETE endpoint

In this section we are going to create a PUT Endpoint manually to update a single record in our Posts Data Model. To do this, head on over to the endpoints tab & press the "+ New Endpoint" button to create a new endpoint.
Next, we fill in the basic details for our endpoint as below.
Basic DELETE Endpoint Details
Note, our Path parameter has the extension {id}. This is going to be used to identify which record in our Posts Data Model we are going to delete.
The id is what is called a "Path Variable". Essentially, the part of our URL that is in curly braces is just a placeholder for a dynamic, or variable value.
Ditto Tip: the reason that we use the id is twofold. First, the id field is automatically added by Dittofi to every row of data inside your data model. Second, the Id value is auto incrementing and therefore is a unique identifier for all rows in your Data Model.
The value of the placeholder or variable "id" can be set inside the Path Variables section of our endpoint.
Note that the in the variable settings, we pick the Kind, Number and give the same name and label as the value inside the curly braces in our Endpoint Path, "id", as below.
Path Variable Popup
The reason we pick the Kind Number is that the id is a number field in our Posts Data Model. The name of our Path Variable also needs to match both in spelling and capitalization of the id inside the curly braces of our Endpoint Path.
The final step is to save our endpoint and close it.

Linking our DELETE Endpoint to an action

Next, we need to link our Delete social media post endpoint to an action. To do this, we start by heading over to the actions tab & pressing "+ New Action".
Next we give our action a name, call it "Delete social media post".
Next, we link our Delete Social Media Post action to our endpoint.
Next, we need to look up the record in the Posts Data Model (the social media post) that we want to delete. To do this, we begin by adding a variable of Kind Model to our action called "PostToDelete". The model we use is our Social Media Posts Model.
Our variable is going to store just one record, that we want to delete. To get just one record out of our data model, we need to add a basic filter. To do this, use the Where clause in the "New Variables" browser, as below.
Notice, that we filter according to the id that is passed into our Delete Social Media Posts Action from our associated endpoint. This value, as we saw in the previous section is variable.
Next we add an Delete Event to our actions and events graph by clicking on the "+ Add Event" button.
Adding a new event
Using the panel on the right hand side of the screen, we can then choose our event type and configure our event. The table below describes what each of the configuration options does.
Option Name
Option Description
Example
Event Type
This is the event type that we want to run.
Delete
Description
This is used to provide a description to our event.
"Event to delete a post."
Object
This is the post that we are looking to delete
In our case, this will be the PostToDelete that we looked up based on the id.
Variables
This is variable that can be declared inside the event. This variable can be used by this event and all subsequent events.
In our example, we don't need to set this variable.
The final configuration for our event looks like the screenshot below.

Testing Our DELETE Endpoint, Action & Event

To test our DELETE Endpoint, Action & Event, we need to (A) generate the code, (B) test our endpoint from within the endpoints tab by adding a dummy id, (C) check our endpoint response code & (D) look at our Posts Data Model to see if the record has been deleted. The video below shows this process in action.
​