n8n Beginner Course (4/9) - How does n8n handle data?
4.63k views1870 WordsCopy TextShare
n8n
⌨ Sign up to n8n Cloud for a free trial: https://app.n8n.cloud/register
Or:
npm install -g n8n
n8n...
Video Transcript:
hello and welcome to video number four of the beginner course of nen um in this video we'll be covering what kinds of data nodes use and how the data is passed from node to node this video is going to be a bit of a longer one um and we'll cover some more technical Concepts but it is very important that you understand these Concepts um so that you can build the best workflows possible possible let's start by explaining some core data Concepts that you need to understand to make the most out of nen there are two main data structures that we are going to take a look at today the first one is what we call a Json and the second one is a list Json are a very common way of storing data digitally and are written between braces or curly brackets they are made up of key value pairs um each one being separated by a comma lists are nothing more than a collection of objects um they can be of the same or different type written between brackets or Square braces um also separated by commas a Json can be embedded what we mean by this is sometimes we will have a Json where the value of a key is equal to another Json we can use this to organize complex data in this example we can use an embedded Json to group all the information about Emily's location into a location key this key contains itself AJ sorry the value of this key is a Json that has two keys with information on M's country and city to access the data in a Json we can use the standard dot notation here doter Json let lets us access the Json itself and by T typing first uncore name we can access the value of the first uncore name key for embedded Json we can use multiple dot notations in a row here to get the location we can write dollar json. location. country Dollar json.
location being itself ajon on which we use the dot notation to to get the value of its key country lists are uh simp are simply a collection of objects uh we can have a mix of letters and numbers uh we could have a list of any type of objects and as you can see here written between square brackets and separated by commas and because Json themselves are OB objects we can obviously make a list of Json here we have the example Json from earlier separated by a comma and then two more Json that form well a list of Json as we can see here we have the square brackets at the top our first Json a comma our second Json comma our third Json and then finally our last uh brace there is a very interesting correspondence between Json and tables where we can tell that one Json is equivalent to one row with the keys being the headers of those rows this might remind you a little bit the Json and table view that we saw in the previous video on ENT nodes here um when we have a list of Json we can see that Emily here first name Emily last name Johnson email and her email fits very well into the row format where we have the different keys that are the different Columns of our table so we can imagine that if we have a list of three Json then we have an equivalent table with three different rows each one with the values of the corresponding Row in nen this is what we call items here in red we have an example of an item we have the first item of the list and node nodes use items plural as inputs and as outputs these are the only accepted formats for node inputs and node outputs even should we decide to return nothing no information we still have to return a list with an empty Json that would be considered the empty output for an nadn node so now let's look into how nodes actually use these items when we're going to be executing them and building workflows each node executes one per item in the input data so there are some exceptions uh that we will be covering in the advanced course but in general you can remember that each node executes once per item for example here we are using the date and time node to format different dates the node will read each item format the date and then return it as an individual item this is how we build workflows by transitioning items through different nodes so here if we look into this screenshot here we have a list of items each with different dates and here as the output we have again three items because it was executed once per item and then we have the formatted date which is the same Associated date but in a different format in the advanced sorry in the parameters of um the node we can access the additional settings through the gear icon and here we can decide to execute only once where a node will execute only for the first item of its input to better understand how uh workflows actually work um here we have an execution schema of a very simple workflow the workflow starts when clicking execute workflow reads data from a Google sheet and then filters the items depending on specific conditions the execute workflow node launches and returns an empty Json so no data at all all and here we can see we have our empty Json in a list this is returned so that the next node can execute once because we have one item the Google Sheets node then executes once and reads three items in the Google sheet that it's reading from and so it returns three items Json one Json 2 and Json 3 each um being linked to the corresponding Row in the Google sheet so we can see it outputs three items the filter node checks if each item satisfies a specific filter condition here we can see that only one of the items does and so it only outputs one item when building workflows the whole point is to configure a node to execute depending on what's in the input data we can do this by dragging the key from the table Json or schema view this will create what we call an expression Expressions will for each item return the associated value to that key the NN interface will show you an example value from the first item so using the same uh data as before in the schema view we can drag the first name key into the filter conditions and I can say I only want to allow through the filter if the first name is equal to something for example Emily here we have the expression editor and we have an example result for item one so here json. first name of item one is equal to Emily remember nodes execute once per item and so as it executes es for each item the expression would have the value Associated to that key everything between two braces or curly brackets is an expression so we can use expressions for many different use cases we can use item variables as we saw before so dollar json. first name json.