> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Storage: Update item

> Updates values of an item saved in a storage.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Updates specific values inside an item that is already saved in a storage, without replacing the whole item. For each update you map a value from the data flowing through your transformation (the source) onto a spot inside the stored item (the destination). Use it to keep a stored record in sync as new data comes in, for example refreshing a price or a status while leaving everything else untouched. The item is looked up by its identifier, the values are written in, and it is saved back under the same identifier. The data flowing through your transformation is passed along unchanged.

This documentation describes: [Schema](/schemas/transformer/storage-update-entity-in-storage)

## Fields

<FormField property="storage" label="Storage" required diType="storage">
  The storage that holds the item. You select a storage that was set up beforehand.
</FormField>

<FormField property="storageKey" label="Storage item identifier" required>
  The identifier of the item to update. [Placeholders](/references/placeholders) are supported, so you can build it from the data, for example `&{sku}`. The value must be present and cannot be empty, otherwise the run stops with an error.
</FormField>

<FormField property="upsert" label="Automatically add item">
  Controls what happens when no item with that identifier exists yet. When turned on, a new item is created and the updates are written into it. When turned off (the default), there is nothing to update and the run simply continues.
</FormField>

<FormField property="updates" label="Data to update in the storage item" required>
  One or more value mappings, added as rows; at least one is required. Each row pairs a Source with a Destination.
</FormField>

<FormField property="updates[].source" label="Source" required>
  The location of a value in the data flowing through your transformation. For example `price` reads the incoming price. [Placeholders](/references/placeholders) are supported.
</FormField>

<FormField property="updates[].destination" label="Destination" required>
  The spot inside the stored item where that value is written. For example a destination of `price` refreshes the stored price, while `inventory.available` writes into a nested spot. [Placeholders](/references/placeholders) are supported.
</FormField>

## Sample data

This transformer reads from and writes to a configured storage backend and leaves your data unchanged, so there is no fixed before and after to show. The example below looks up the item whose identifier matches the `sku` field, then refreshes its price from the incoming `price` and its available stock from the incoming `stock`. With Automatically add item turned off, an item that does not exist yet is left alone.

| Field                   | Value                                               |
| ----------------------- | --------------------------------------------------- |
| Storage                 | A storage set up beforehand                         |
| Storage item identifier | `&{sku}`                                            |
| Automatically add item  | Off                                                 |
| Update 1                | Source `price` to Destination `price`               |
| Update 2                | Source `stock` to Destination `inventory.available` |

```json Configuration theme={null}
{
  "prototype": "storage-update-entity-in-storage",
  "parameters": {
    "storage": { "prototype": "storage", "parameters": {} },
    "storageKey": "&{sku}",
    "upsert": false,
    "updates": [
      { "source": "price", "destination": "price" },
      { "source": "stock", "destination": "inventory.available" }
    ]
  }
}
```
