Hierarchy Store
Component Detail
Data Layer
high complexity
backend
0
Dependencies
3
Dependents
5
Entities
0
Integrations
Description
Data access layer managing the organization hierarchy closure table in PostgreSQL. Handles CRUD operations for organizations and their parent-child relationships, maintains the closure table for efficient tree queries, and manages materialized views for aggregate report data.
hierarchy-store
Responsibilities
- Maintain closure table entries for organization parent-child relationships
- Execute efficient ancestor and descendant queries without recursive CTEs
- Manage materialized view refresh for nightly aggregate statistics
- Seed initial hierarchy from existing organization data via migration scripts
- Ensure referential integrity when moving or deleting hierarchy nodes
Interfaces
findById(orgId): Organization
findChildren(parentOrgId): Organization[]
findAncestors(orgId): Organization[]
findDescendants(orgId): Organization[]
insertOrganization(org): Organization
insertClosureEntries(orgId, parentOrgId): void
updateParent(orgId, newParentOrgId): void
removeClosureEntries(orgId): void
deleteOrganization(orgId): void
getSubtreeDepth(orgId): number
refreshAggregateViews(): void
findByScope(scopeOrgIds): Organization[]
Relationships
Dependents (3)
Components that depend on this component
Related Data Entities (5)
Data entities managed by this component