getNodeByIndex
A function to get a pre-existing node from your database via a defined unique index.
(Note: by default, all nodes have nodeId
as a unique index, but they can be defined using the defineUniqueIndex
method as shown here)
Parameters:
nodeType
: string, the node type you wish to fetchuniqueIndexType
: string, the unique index you wish to search foruniqueIndex
: string, the unique index itself
Output:
data
: the data from the node you wish to fetch consistent with the NodeType's stateSchema, null if errorerror
: the error that occurred, null if operation successful
Example
Code:
import { getNodeByIndex } from "../uix/functionModule"
const fetchedNode = await getNodeByIndex("User", "username", "johndoe")
return fetchedNode
Output:
{
data: {
username: "johndoe",
password: "dj32wdi2n393ndunwieudnqijwd9oasimdoajsfe",
lastLoginTime: "2024-07-05T15:20:10Z"
},
error: null
}
(Note: any unique index other than nodeId must be defined using the defineUniqueIndexes method)