Build Map
The Build Map node is used to create a new JSON / Object variable, with optional Key-Value pairs which should only be included if a certain condition is met.
This node is super helpful when we need to add keys based on certain conditions, such as existence in query params, etc so that we can build a dynamic object to query the database. Check the examples below for more inspiration.
Properties Panel
General
Field | Description | Required |
---|---|---|
Node name | true | |
Variable name | Name of the JSON variable you need to create | true |
List of BuildMap objects | A list of buildmap objects where each object mentions the condition based on which to add a certain key/value pair in the final JSON object. You can use Magical Autocomplete with keys, values and conditions. | true |
Returns
This node does not return any value, but sets a variable with your provided <name>
in the flow context.
Examples
For example, if you have a Listing / Search API and would need to build a custom query object for the database (find or $match stage), you can use this node and provide the following list of buildmap objects -
The above buildmap objects list will iterate over each object to check if the condition is true or not, and if it is true
, then will add the key-value pair to the following object.
Assuming above that name and jobTitle is not equal to null, but age is less than 10, this will result in a JSON variable as such -
Last updated