add page on data mocking

This commit is contained in:
Deborah Barnard 2024-04-16 12:07:17 +01:00
parent 861e24e262
commit b8aae9178f
4 changed files with 47 additions and 8 deletions

View File

@ -0,0 +1,8 @@
To pin data in a node:
1. Run the node to load data.
2. In the **OUTPUT** view, select **Pin data** <span class="inline-image">![Pin data icon](/_images/data/data-pinning/data-pinning-button.png){.off-glb}</span>. When data pinning is active, the button changes to show this <span class="inline-image">![Active pin data icon](/_images/data/data-pinning/data-pinning-button-active.png){.off-glb}</span>.
/// note | Nodes that output binary data
You can't pin data if the output data includes binary data.
///

37
docs/data/data-mocking.md Normal file
View File

@ -0,0 +1,37 @@
---
title: Data mocking
description: Ways to mock data in your n8n workflow.
contentType: howto
---
# 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](/data/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](/data/data-editing/).
Use this approach when you need to configure your workflow to handle the exact data structure and parameters provided by your data source.
--8<-- "_snippets/data/how-to-pin-data.md"
## Mock data using the Code or Edit Fields nodes
You can create a custom dataset in your workflow using either the [Code node](/integrations/builtin/core-nodes/n8n-nodes-base.code/) or the [Edit Fields (Set) node](/integrations/builtin/core-nodes/n8n-nodes-base.set/).
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.
Use this approach if you need some test data when exploring n8n, and you don't have a real use-case to work with.

View File

@ -19,14 +19,7 @@ Data pinning isn't available for production workflow executions. It's a feature
## Pin data
To pin data in a node:
1. Run the node to load data.
2. In the **OUTPUT** view, select **Pin data** <span class="inline-image">![Pin data icon](/_images/data/data-pinning/data-pinning-button.png){.off-glb}</span>. When data pinning is active, the button changes to show this <span class="inline-image">![Active pin data icon](/_images/data/data-pinning/data-pinning-button-active.png){.off-glb}</span>.
/// note | Nodes that output binary data
You can't pin data if the output data includes binary data.
///
--8<-- "_snippets/data/how-to-pin-data.md"
## Unpin data

View File

@ -287,6 +287,7 @@ nav:
- Data pinning: data/data-pinning.md
- Data editing: data/data-editing.md
- Data filtering: data/data-filtering.md
- Data mocking: data/data-mocking.md
- Binary data: data/binary-data.md
- Manage n8n Cloud:
- Overview: manage-cloud/overview.md