Infrastructure medium complexity backend
0
Dependencies
2
Dependents
1
Entities
0
Integrations

Description

Utility for constructing parameterized recursive Common Table Expression SQL fragments in PostgreSQL for arbitrary-depth tree traversal. Ensures query safety, depth bounding, and consistent result mapping across all hierarchy traversal operations.

Feature: Multi-Organization Hierarchy

recursive-cte-query-builder

Responsibilities

  • Generate safe parameterized recursive CTE SQL for ancestor and descendant queries
  • Enforce a configurable maximum recursion depth to prevent runaway queries on corrupted data
  • Provide typed row-to-domain-object mappers for organization tree results

Interfaces

buildAncestorCTE(anchorId: string, maxDepth: number): SqlFragment
buildDescendantCTE(anchorId: string, maxDepth: number): SqlFragment
mapRowToOrganizationNode(row: Record<string, unknown>): OrganizationNode

Relationships

Dependents (2)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component