Unit Assignment Repository
Component Detail
Data Layer
medium complexity
Shared Component
backendshared
0
Dependencies
2
Dependents
1
Entities
0
Integrations
Description
Data access layer for the user_organization_unit_assignments junction table. Manages user-to-unit relationships including the is_primary flag. Supports batch inserts for initial hierarchy setup and enforces uniqueness constraints at the query level before hitting the database.
unit-assignment-repository
Responsibilities
- CRUD operations on user_organization_unit_assignments table
- Enforce unique primary assignment per user per organization before insert
- Batch insert assignments for bulk user setup
- Provide user counts per unit for admin displays
Interfaces
fetchByUser(userId, organizationId)
fetchByUnit(unitId)
insert(userId, unitId, isPrimary)
updatePrimary(userId, unitId, isPrimary)
delete(userId, unitId)
countByUnit(unitId)
batchInsert(assignments)
Relationships
Dependents (2)
Components that depend on this component