# Update

The `Update` node can be used to make changes to complex data in an easy way. In the example below, we append a string to the value of a nested object.

<figure><img src="/files/E5vtDPL2mYUgT47zG2Zl" alt=""><figcaption></figcaption></figure>

Update has three (+ 1) inputs:

1. `input` is the data you want to make changes to
2. the second input is a path expression that specifies a sub part of the object to change.
3. `value` is the new value we want to put at that position
4. You can also change between various update modes using the dropdown in the header
   1. `Append` appends `value` to the original value (like in the example above). For strings and lists this means they get concatenated.
   2. `Replace` replaces the original value with `value`
   3. `Remove` removes item pointed to by the path expression. In this case, the `value` input is not used for anything.

## Benefits of using the Update node

The update node makes is super easy to make changes to complex objects, but an added benefit is that it does so without changing the original object, but instead returns a new one, which is a complete clone of the original input object, but with your specified update. This help prevent unintended side effects, making your flows more predictable and easier to debug.

## Path expressions

Path expressions describe accessors for parts of complex objects. The `.` operator is used to access fields of objects, while the index operator `[<index>]` is used to access items in lists or characters in strings. Path expressions also support expressions in the indexer position, which can be used to calculate offsets or retrieve values based on inputs or variables. Here are some examples.

### Change the age field of the third user item

<div data-full-width="false"><figure><img src="/files/JtTjY9ivoXEblDarZDmz" alt=""><figcaption></figcaption></figure></div>

### Append a token to the content field of object described by an id

<figure><img src="/files/sNBrLWSFo8WZ2Y77gnjh" alt=""><figcaption></figcaption></figure>

### More valid path expressions

* `input[a + b].foo` - using inputs (`a` and `b`) in the path expression gives additional inputs to the update node that you can connect to
* `input` - leaving just the input part just returns the existing object
* `input["hello"]` - the hello field of an object like `{ hello: "there" }`&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.midio.com/midio-docs/reference/the-midio-language/update.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
