Skip to content

数据模拟#

¥Data mocking

数据模拟是指模拟或伪造数据。这在开发工作流时非常有用。通过模拟数据,你可以:

¥Data mocking is simulating or faking data. It's useful when developing a workflow. By mocking data, you can:

  • 避免重复调用数据源。这可以节省时间和成本。

¥Avoid making repeated calls to your data source. This saves time and costs.

  • 在初始开发阶段使用小型、可预测的数据集。

¥Work with a small, predictable dataset during initial development.

  • 避免覆盖实时数据的风险:在构建工作流的早期阶段,你无需连接实际数据源。

¥Avoid the risk of overwriting live data: in the early stages of building your workflow, you don't need to connect your real data source.

使用数据绑定进行真实数据模拟#

¥Mocking with real data using data pinning

使用 数据固定,你可以将真实数据加载到工作流中,然后将其固定在节点的输出面板中。使用这种方法,你只需调用一次数据源即可获得真实数据。你可以 编辑已固定数据

¥Using data pinning, you load real data into your workflow, then pin it in the output panel of a node. Using this approach you have realistic data, with only one call to your data source. You can edit pinned data.

如果你需要配置工作流以处理数据源提供的确切数据结构和参数,请使用此方法。

¥Use this approach when you need to configure your workflow to handle the exact data structure and parameters provided by your data source.

To pin data in a node:

  1. Run the node to load data.
  2. In the OUTPUT view, select Pin data Pin data icon. When data pinning is active, the button is disabled and a "This data is pinned" banner is displayed in the OUTPUT view.

Nodes that output binary data

You can't pin data if the output data includes binary data.

使用“代码”或“编辑字段”节点生成自定义数据#

¥Generate custom data using the Code or Edit Fields nodes

你可以使用 代码节点编辑字段(集)节点 在工作流中创建自定义数据集。

¥You can create a custom dataset in your workflow using either the Code node or the Edit Fields (Set) node.

在“代码”节点中,你可以创建所需的任何数据集,并将其作为节点输出返回。在“编辑字段”节点中,选择“添加字段”以添加你的自定义数据。

¥In the Code node, you can create any data set you want, and return it as the node output. In the Edit Fields node, select Add fields to add your custom data.

“编辑字段”节点非常适合小型测试。要创建更复杂的数据集,请使用代码节点。

¥The Edit Fields node is a good choice for small tests. To create more complex datasets, use the Code node.

从客户数据存储节点输出示例数据集#

¥Output a sample data set from the Customer Datastore node

客户数据存储节点提供一个可供使用的虚拟数据集。添加并执行节点以探索数据。

¥The Customer Datastore node provides a fake dataset to work with. Add and execute the node to explore the data.

如果你在探索 n8n 时需要一些测试数据,但没有实际用例,请使用此方法。

¥Use this approach if you need some test data when exploring n8n, and you don't have a real use-case to work with.