# Set

### Overview

The **Set Storage Component** stores a key-value pair in a specified storage location, enabling structured data persistence within workflows.

### Usage

This component allows users to store data dynamically by assigning a value to a key in a designated storage space.

#### Input Ports

| Port | Description                               |
| ---- | ----------------------------------------- |
| `in` | Receives the key-value pair to be stored. |

#### Output Ports

| Port  | Description                                                          |
| ----- | -------------------------------------------------------------------- |
| `out` | Emits the stored key, old value (if any), new value, and timestamps. |

#### Properties

| Property  | Type     | Description                                                          |
| --------- | -------- | -------------------------------------------------------------------- |
| `storeId` | `string` | The ID of the storage space where the key-value pair will be stored. |

#### Processing Logic

1. **Receives Key-Value Pair**: Accepts an input with a key and its corresponding value.
2. **Stores Data**: Saves the key-value pair in the specified `storeId`.
3. **Handles Updates**:
   * If the key already exists, updates its value and retains the previous value.
   * If the key is new, creates a fresh entry.
4. **Emits Output**: Sends the key, old value, new value, and timestamps to the `out` port.

#### Output Data Schema

| Property    | Type     | Description                                              |
| ----------- | -------- | -------------------------------------------------------- |
| `key`       | `string` | The key associated with the stored value.                |
| `oldValue`  | `string` | The previous value (if the key existed).                 |
| `newValue`  | `string` | The newly stored value.                                  |
| `createdAt` | `string` | Timestamp when the key-value pair was initially created. |
| `updatedAt` | `string` | Timestamp when the key-value pair was last updated.      |

### Notes

* **Dynamic Data Storage**: Supports both new entries and updates to existing keys.
* **Efficient Workflow Integration**: Allows seamless data persistence for automation.
* **Timestamp Tracking**: Keeps track of creation and update times for data integrity.

This component is essential for workflows that require structured data storage and retrieval within automated processes.
