> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/Duaer-Organizations/executions/custom-executions-data.md).

# 在 Duaer 里自定义执行数据

在 Duaer 里，用 Code 节点或 Execution Data 节点给这次执行加上自定义数据，之后可在执行列表里按这些值筛选。
自定义数据记在这一次执行上。它不是节点之间传递的 json。执行列表里按自定义数据筛选，需要套餐包含这项。

## 用 Code 节点写入与读取 <a href="#set-and-access-custom-data-using-the-code-node" id="set-and-access-custom-data-using-the-code-node"></a>

下面用 Code 节点。也可用 Execution Data 节点写入；该节点不能把值取回。

写入单个键：

```
$execution.customData.set("key", "value");
```

一次写入全部自定义数据。这会覆盖本次执行上已有的整份自定义数据对象：

```
$execution.customData.setAll({"key1": "value1", "key2": "value2"});
```

限制：

- 键和值都必须是字符串。
- 键最长 50 个字符。
- 值最长 255 个字符。
- 最多 10 条自定义数据。

在同一次执行里读取：

```
const all = $execution.customData.getAll();
const one = $execution.customData.get("key");
```

## Python

Python Code 节点用 _execution.customData，方法相同：

```
_execution.customData.set("key", "value")
_execution.customData.setAll({"key1": "value1", "key2": "value2"})
all_data = _execution.customData.getAll()
one = _execution.customData.get("key")
```

## 用 Execution Data 节点写入

不想写代码时，用 Execution Data 节点填键和值。跑到这一步就会记到当前执行上。要在后面的代码里读，仍用上面的 get / getAll。
## Questions

### 自定义执行数据存在哪里、做什么用？

在 Duaer 里，存在这一次执行记录上，是键值对，用来稍后在执行列表里筛选。它不是节点之间传递的 json。筛选需要套餐包含该能力。

### 怎么在 Code 节点里写入？

在 Duaer 里，用 $execution.customData.set 写一个键，或 setAll 一次写多个（会覆盖整份对象）。值必须是字符串；键最长 50，值最长 255，最多 10 条。Python 用 _execution.customData。

