diff --git a/_snippets/data/data-mapping/how-to-pin-data.md b/_snippets/data/data-mapping/how-to-pin-data.md new file mode 100644 index 000000000..60d138372 --- /dev/null +++ b/_snippets/data/data-mapping/how-to-pin-data.md @@ -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** ![Pin data icon](/_images/data/data-pinning/data-pinning-button.png){.off-glb}. When data pinning is active, the button changes to show this ![Active pin data icon](/_images/data/data-pinning/data-pinning-button-active.png){.off-glb}. + +/// note | Nodes that output binary data +You can't pin data if the output data includes binary data. +/// diff --git a/docs/data/data-mocking.md b/docs/data/data-mocking.md new file mode 100644 index 000000000..e2d8afe69 --- /dev/null +++ b/docs/data/data-mocking.md @@ -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. diff --git a/docs/data/data-pinning.md b/docs/data/data-pinning.md index ce108b0af..331f5688b 100644 --- a/docs/data/data-pinning.md +++ b/docs/data/data-pinning.md @@ -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** ![Pin data icon](/_images/data/data-pinning/data-pinning-button.png){.off-glb}. When data pinning is active, the button changes to show this ![Active pin data icon](/_images/data/data-pinning/data-pinning-button-active.png){.off-glb}. - -/// 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 diff --git a/mkdocs.yml b/mkdocs.yml index aeb206bb7..bae9ecfe2 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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