app.repository.user_repository module¶
- class app.repository.user_repository.UserRepository(session_factory, model=<class 'app.model.users.Users'>)[source]¶
Bases:
BaseRepositoryRepository class for users.
- Parameters:
session_factory (Callable[[...], AbstractAsyncContextManager[AsyncSession]])
- async create_user_by_externalUserId(externalUserId, oauth_user_id=None)[source]¶
Creates a new user with the provided external user ID.
Concurrency-safe: when a parallel transaction inserts the same externalUserId first, returns the already-existing row instead of raising IntegrityError to the caller.
- Parameters:
externalUserId (str)
oauth_user_id (str | None)
- Return type:
- async get_or_create_by_externalUserId(externalUserId, oauth_user_id=None, session=None, auto_commit=True)[source]¶
Returns an existing user by externalUserId or creates it atomically via
INSERT ... ON CONFLICT DO UPDATE.- Parameters:
externalUserId (str)
oauth_user_id (str | None)
session (AsyncSession | None)
auto_commit (bool)
- Return type: