* Get immediate children of a node * * @param nodeId - ID of the node * @returns Array of child nodes
(nodeId: string)
| 718 | * @returns Array of child nodes |
| 719 | */ |
| 720 | getChildren(nodeId: string): Node[] { |
| 721 | const containsEdges = this.queries.getOutgoingEdges(nodeId, ['contains']); |
| 722 | if (containsEdges.length === 0) return []; |
| 723 | |
| 724 | // Batch-fetch (was N+1). |
| 725 | const childNodes = this.queries.getNodesByIds(containsEdges.map((e) => e.target)); |
| 726 | const children: Node[] = []; |
| 727 | for (const edge of containsEdges) { |
| 728 | const childNode = childNodes.get(edge.target); |
| 729 | if (childNode) children.push(childNode); |
| 730 | } |
| 731 | return children; |
| 732 | } |
| 733 | } |
no test coverage detected