Data Layer high complexity Shared Component backendshared
0
Dependencies
6
Dependents
1
Entities
0
Integrations

Description

Supabase data access layer for the organization_units table which implements a recursive adjacency-list structure (parent_id self-reference). Provides typed Dart models and query methods for fetching subtrees, finding ancestors, and performing safe cascade deletes.

Feature: Organizational Hierarchy & Structure Management

organization-unit-repository

Responsibilities

  • CRUD operations against organization_units table
  • Recursive subtree queries using Supabase RPC or recursive CTEs
  • Return typed OrganizationUnit Dart models
  • Handle soft-delete and cascade constraints

Interfaces

fetchAll(organizationId)
fetchById(unitId)
fetchChildren(parentId)
fetchAncestors(unitId)
fetchDescendants(unitId)
insert(organizationId, name, levelType, parentId?)
update(unitId, patch)
softDelete(unitId)
countMembers(unitId)

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/organization-units 7 endpoints
GET /api/v1/organization-units Fetch all units for an organization (flat list)
GET /api/v1/organization-units/{unitId} Fetch a single unit by ID
GET /api/v1/organization-units/{unitId}/children Fetch direct children of a unit
GET /api/v1/organization-units/{unitId}/ancestors Fetch all ancestor units up to the root
POST /api/v1/organization-units Insert a new organization unit record
PUT /api/v1/organization-units/{unitId} Update an organization unit record
+1 more