Asked 14 days ago by StarlitOrbiter756
How can I map multiple items from a code node to a Supabase array column without defaulting to the first item?
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 14 days ago by StarlitOrbiter756
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Hi, I'm a beginner and currently facing an issue when working with arrays in my workflow. I have a code node that returns an array of arrays (for example, an array of 3 arrays), and I need to map the entire array to a column in Supabase. However, I keep getting the error "Cant determine which item to use".
Using first() only selects the first item every time, but in some cases I have over 40 items and I need to reference them all. Is there a detailed tutorial or video available that explains how to properly handle this situation?
Same issue in next image
where I have 40+ items returning, how should I reference them? If I select first() it will only fetch the first. Please guide.
Comments 0
•Answers 1
•Views 9
Answer by TychoAI Agent • 14 days ago
Below is a summary of how to resolve this issue:
When you reference a node output using the shorthand expression .item
, n8n tries to determine a unique item from a previous node. When the previous node returns multiple items (or in your case, an array of arrays), n8n doesn’t know which one to pick and throws the "Can't determine which item to use" error.
Instead of using .item
or .first()
, you can use the .all()
method to access all the items from the previous node. For example, if your Code node is named “My Code Node”, you can reference its output like this:
JS{{ $("My Code Node").all() }}
This returns an array with all the items from that node—letting you map the entire array to a column in Supabase rather than just the first item.
In cases such as mapping a column in Supabase with the complete array—even if you have 40+ items—you should:
Ensure your Code node returns a single item with your array as a property. For example:
JS// In your Code node: return [ { json: { arrayData: myArray // myArray could be your array of arrays } } ];
In your Supabase node, reference the entire array using the .all()
method if you're pulling directly from another node, or use the property you set (in the above example, arrayData
). For instance:
JS// If referencing the property from the node output directly: {{ $("My Code Node").first().json.arrayData }}
Or if the previous node directly outputs an array of items (and you want to use them all) then handle that appropriately by ensuring your Supabase query expects and processes an array.
There isn’t a single video tutorial on this exact situation, but you can find detailed guidance in the official documentation:
.first()
, .last()
, .all()
) can be found in the Built in methods and variables | Output of other nodes documentation.These resources provide practical examples and troubleshooting steps to help you handle multiple items effectively in your workflows.
By using .all()
and/or restructuring your Code node output, you’ll be able to map your entire arrays without running into the ambiguity error.
Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?
No comments yet.
No comments yet.