createNode
A function to create a node configured in your uix.config.ts
file.
Parameters:
parentNodeKeys
: an array of nodeKeys ({nodeType, nodeId}
) that specify the parent nodes for the node you are creatingnodeType
: the node type to be generated (must be defined in your config)initialState
: the initial state of the node to be generated, consistent with the nodeType specified's stateSchemanodeId
(optional): an option to set the nodeId as desired, if left unspecified one will be generated for you viauuid()
Output:
data
: the data of the node you created consistent with the nodeType's stateSchema, null if an error occurederror
: the error that occurred, null if operation successful
Example
Code:
import { createNode } from "../uix/functionModule"
const createdNode = await createNode(
[{nodeType: "User", nodeId: "u2md320-dm2e-ic2ncu0n2"}],
"Profile",
{
firstName: "John",
lastName: "Doe",
age: 20
}
)
return createdNode
Output:
{
data: {
firstName: "John",
lastName: "Doe",
age: 20
},
error: null
}