Class: AuctionFunCore::Repos::UserContext::UserRepository
- Inherits:
-
Object
- Object
- AuctionFunCore::Repos::UserContext::UserRepository
- Defined in:
- lib/auction_fun_core/repos/user_context/user_repository.rb
Overview
Repository for handling repository operations related to users.
This repository provides methods to interact with user data in the database, including creating, updating, deleting, and retrieving users.
Instance Method Summary collapse
-
#all ⇒ Array<ROM::Struct::User>
Returns all users in database.
-
#by_email_confirmation_token(email_confirmation_token) ⇒ ROM::Struct::User?
Searches for a user in the database by email confirmation token.
-
#by_id(id) ⇒ ROM::Struct::User?
Retrieves a user from the database by its primary key.
-
#by_id!(id) ⇒ ROM::Struct::User
Retrieves a user from the database by its primary key, raising an error if not found.
-
#by_login(login) ⇒ ROM::Struct::User?
Searches for a user in the database by email or phone keys.
-
#by_phone_confirmation_token(phone_confirmation_token) ⇒ ROM::Struct::User?
Searches for a user in the database by phone confirmation token.
-
#count ⇒ Integer
Returns the total number of users in database.
-
#exists?(conditions) ⇒ Boolean
Checks if a user exists based on the provided conditions.
-
#query(conditions) ⇒ AuctionFunCore::Relations::Users
Constructs SQL conditions for querying users in the database.
Instance Method Details
#all ⇒ Array<ROM::Struct::User>
Returns all users in database.
48 49 50 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 48 def all users.to_a end |
#by_email_confirmation_token(email_confirmation_token) ⇒ ROM::Struct::User?
Searches for a user in the database by email confirmation token.
99 100 101 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 99 def by_email_confirmation_token(email_confirmation_token) users.where(Sequel[email_confirmation_token: email_confirmation_token]).one end |
#by_id(id) ⇒ ROM::Struct::User?
Retrieves a user from the database by its primary key.
71 72 73 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 71 def by_id(id) users.by_pk(id).one end |
#by_id!(id) ⇒ ROM::Struct::User
Retrieves a user from the database by its primary key, raising an error if not found.
81 82 83 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 81 def by_id!(id) users.by_pk(id).one! end |
#by_login(login) ⇒ ROM::Struct::User?
Searches for a user in the database by email or phone keys.
90 91 92 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 90 def by_login(login) users.where(Sequel[email: login] | Sequel[phone: login]).one end |
#by_phone_confirmation_token(phone_confirmation_token) ⇒ ROM::Struct::User?
Searches for a user in the database by phone confirmation token.
108 109 110 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 108 def by_phone_confirmation_token(phone_confirmation_token) users.where(Sequel[phone_confirmation_token: phone_confirmation_token]).one end |
#count ⇒ Integer
Returns the total number of users in database.
54 55 56 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 54 def count users.count end |
#exists?(conditions) ⇒ Boolean
Checks if a user exists based on the provided conditions.
116 117 118 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 116 def exists?(conditions) users.exist?(conditions) end |
#query(conditions) ⇒ AuctionFunCore::Relations::Users
Constructs SQL conditions for querying users in the database.
62 63 64 |
# File 'lib/auction_fun_core/repos/user_context/user_repository.rb', line 62 def query(conditions) users.where(conditions) end |