deleteRecord Documentation
Overview
The deleteRecord logic is designed for the Vantage analytics and data platform, specifically for deleting records from the contacts application or any specified data set. It allows users to remove records based on provided identifiers either from direct input or from an upstream data source. This functionality is critical in maintaining data integrity and managing data lifecycle effectively within the platform.
Settings
The deleteRecord logic includes several configurable settings that dictate its behavior and define how data is processed. Below is a detailed explanation of each setting:
1. recordId
- Input Type: String
- Description: This setting specifies a particular record that is to be deleted from the contacts application. If set, this parameter will take precedence over the input data provided in
inputs. - Behavior: If a
recordIdis specified, the logic will delete only that single record. If this is not set, the logic will rely on theidColumnto find records in the provided data set for deletion. - Default Value:
undefined
2. idColumn
- Input Type: String
- Description: This setting defines the name of the column that holds the record ID in the upstream dataset. It allows the logic to identify which records to delete based on the values in this column.
- Behavior: If provided, the logic will use this value to search the input data for record IDs. If not configured, it defaults to using "id" as the column name.
- Default Value:
id
How It Works
The deleteRecord logic executes asynchronously and processes requests as follows:
- Context Validation: It checks for the presence of a
clientId. If this is absent, the function exits early, returning an error. - Adapter Initialization: Using the client ID and application type, an app data adapter is created, which connects to the respective storage provider defined in the app configuration.
- Input Handling: The logic takes inputs from various sources, prioritizing
inputs.data, followed byinputs.input1?.data, and finally interpreting a single input as an array if necessary. - Record Deletion:
- If a
recordIdis provided, it deletes that specific record. - If no static ID is available, it iterates through the provided input data, extracting IDs based on the
idColumnand performing deletions as needed.
- If a
- Output Generation: After deletions, it returns a structured output indicating which records were successfully deleted.
Expected Data
The deleteRecord function expects input data in the following format:
- Input Structure: The
datafield can be either an object or an array.- If using an array, each item must include a valid record identifier either as
idor as specified byidColumn.
- If using an array, each item must include a valid record identifier either as
Example input object:
{
"data": [
{"id": "123"},
{"id": "456"}
]
}Or:
{
"data": {"id": "789"}
}Use Cases & Examples
Use Case 1: Batch Record Deletion
A company regularly cleans its customer database by deleting inactive or outdated contact records. They can utilize the deleteRecord logic to specify a list of record IDs and automate the deletion process based on criteria defined in their upstream data.
Use Case 2: Single Record Management
A user requires the capability to remove a single contact record when a request to delete is made. The user can employ the recordId setting to specify the unique identifier of the contact they wish to delete.
Use Case 3: Integrating with an Upstream Data Pipeline
In a data pipeline scenario, when tracking, a downstream process generates a list of user engagements that require deleting outdated records. By mapping the engagement data to the idColumn, Vantage can automate the deletion of specified records efficiently.
Concrete Example Configuration
Scenario: Automate the deletion of multiple outdated contacts based on an uploaded dataset.
Configuration:
{
"inputs": {
"data": [
{"email": "oldcontact1@example.com"},
{"email": "oldcontact2@example.com"}
]
},
"config": {
"idColumn": "email"
},
"context": {
"clientId": "client-123",
"userId": "user-456",
"nodeType": "contacts/deleteRecord"
}
}In this example:
- The function is configured to look for records based on the
emailcolumn as the identifier for deletion. - It expects the input data to contain an array with objects that hold the email addresses of the contacts to be removed.
By employing this configuration, users can efficiently manage their contacts within the Vantage platform, ensuring that outdated records are purged promptly.