Role Assignment Repository
Component Detail
Data Layer
low complexity
backend
0
Dependencies
1
Dependents
0
Entities
0
Integrations
Description
Data access layer for reading and writing the user_roles junction table. Manages upsert logic for role changes (a user may hold at most one active role per organization), and provides queries needed by the service layer including fetching current role and listing roles within an org.
role-assignment-repository
Responsibilities
- Upsert role assignment in user_roles (user_id, organization_id, role_id, local_association_id)
- Delete role assignment row when a role is removed
- Query current active role for a user within a specific organization
- List all role assignments for a given organization for admin overview
Interfaces
upsertRoleAssignment(assignment: UserRoleRecord): Promise<UserRoleRecord>
deleteRoleAssignment(userId: string, orgId: string): Promise<void>
findActiveRole(userId: string, orgId: string): Promise<UserRoleRecord | null>
findByOrganization(orgId: string): Promise<UserRoleRecord[]>