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

Description

Low-level PostgreSQL adapter that encapsulates all SQL for the closure table pattern on the organizations table. Generates correct INSERT, DELETE, and SELECT statements for maintaining transitive closure relationships and wraps operations in database transactions to ensure consistency during node moves.

Feature: Multi-Organization Hierarchy

closure-table-adapter

Responsibilities

  • Generate and execute closure table INSERT statements for new nodes
  • Execute transactional DELETE and re-INSERT for node moves
  • Provide parameterized queries for ancestor and descendant lookups
  • Ensure referential integrity during subtree deletions

Interfaces

insertClosureRows(orgId, parentId, db): void
deleteClosureRows(orgId, db): void
moveClosureRows(orgId, newParentId, db): void
queryAncestors(orgId): Promise<string[]>
queryDescendants(orgId): Promise<string[]>
queryDepth(orgId): Promise<number>
runInTransaction(operations): Promise<void>

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component