Object
Create
Object Create
The Object Create node allows you to create a new JavaScript object in your Magick spell. It’s a fundamental node for working with data in a structured format.
Inputs
flow
(required): The input flow that triggers the creation of the new object.
Outputs
flow
: The output flow after the object has been created, allowing you to chain further actions.object
: The newly created JavaScript object.
Configuration
hiddenProperties
: An array of property names that should be hidden from the node’s configuration interface. By default, this includes["hiddenProperties", "valueTypes", "valueTypeOptions"]
.socketValues
: An array specifying the types of values that can be added as properties to the object. The default value is["string", "array", "boolean", "integer"]
.socketInputs
: An array where you can define the names and types of the object’s properties. Each array element should be an object withname
andvalueType
properties.
Usage
- Add the Object Create node to your spell.
- Connect the input
flow
to the desired trigger or previous node’s output. - In the node’s configuration panel, click the ”+” button to add properties to the object.
- For each property, enter a name and select a type from the dropdown (string, array, boolean, or integer).
- Enter the desired values for each property.
- Connect the
object
output to other nodes that need to use the created object. - Connect the
flow
output to the next action you want to perform after the object is created.
Example
Here’s an example of how to use the Object Create node to create a user object:
- Add an Object Create node to your spell.
- Configure the node with the following properties:
name
(string): “John Doe”age
(integer): 30email
(string): “john@example.com”subscribed
(boolean): true
- Connect the
object
output to a Debug node to log the created user object. - Run the spell and check the debug output to see the created object:
Best Practices
- Use meaningful names for your object properties to keep your spell easy to understand.
- Be mindful of the property types you choose. Make sure they match the expected data format.
- If you have many properties, consider breaking them down into smaller, more focused objects to improve readability and maintainability.
Common Issues
- Forgetting to connect the
flow
input can prevent the object from being created. - Incorrect property types can lead to unexpected behavior when using the object in other nodes.
- If you don’t see your desired property type in the dropdown, make sure it’s included in the
socketValues
configuration array.