Users Repository
Component Detail
Data Layer
medium complexity
Shared Component
backend
0
Dependencies
4
Dependents
1
Entities
0
Integrations
Description
Data access layer for the users and user_roles tables. Provides org-scoped CRUD operations with indexed PostgreSQL queries supporting pagination, full-text search on name/email, and filtering by role, status, and local association. Never hard-deletes records to preserve audit integrity.
users-repository
Responsibilities
- Execute org-scoped paginated queries on users and user_roles with index utilization
- Insert new user records during invitation acceptance flow
- Update user profile fields and is_active status atomically
- Query user role assignments joined with organizations and local_associations
Interfaces
findByOrg(orgId: string, params: UserQueryParams): Promise<PaginatedResult<UserRecord>>
findById(userId: string): Promise<UserRecord | null>
findByEmail(email: string, orgId: string): Promise<UserRecord | null>
create(data: NewUserData): Promise<UserRecord>
update(userId: string, updates: Partial<UserRecord>): Promise<UserRecord>
deactivate(userId: string): Promise<void>
getRoleAssignments(userId: string): Promise<UserRoleRecord[]>
Relationships
Dependents (4)
Components that depend on this component