Class: AuctionFunCore::Repos::StaffContext::StaffRepository
- Inherits:
-
Object
- Object
- AuctionFunCore::Repos::StaffContext::StaffRepository
- Defined in:
- lib/auction_fun_core/repos/staff_context/staff_repository.rb
Overview
Repository for handling repository operations related to staffs.
This repository provides methods to interact with staff data in the database, including creating, updating, deleting, and retrieving staffs.
Instance Method Summary collapse
-
#all ⇒ Array<ROM::Struct::Staff>
Returns all staffs in database.
-
#by_id(id) ⇒ ROM::Struct::Staff?
Retrieves an staff from the database by its primary key.
-
#by_id!(id) ⇒ ROM::Struct::Staff
Retrieves an staff from the database by its primary key, raising an error if not found.
-
#by_login(login) ⇒ ROM::Struct::Staff?
Searches for a staff in the database by email or phone keys.
-
#count ⇒ Integer
Returns the total number of staffs in the database.
-
#exists?(conditions) ⇒ Boolean
Checks if a bid exists based on the provided conditions.
-
#query(conditions) ⇒ AuctionFunCore::Relations::Staff
Constructs SQL conditions for querying staffs in the database.
Instance Method Details
#all ⇒ Array<ROM::Struct::Staff>
Returns all staffs in database.
49 50 51 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 49 def all staffs.to_a end |
#by_id(id) ⇒ ROM::Struct::Staff?
Retrieves an staff from the database by its primary key.
73 74 75 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 73 def by_id(id) staffs.by_pk(id).one end |
#by_id!(id) ⇒ ROM::Struct::Staff
Retrieves an staff from the database by its primary key, raising an error if not found.
83 84 85 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 83 def by_id!(id) staffs.by_pk(id).one! end |
#by_login(login) ⇒ ROM::Struct::Staff?
Searches for a staff in the database by email or phone keys.
92 93 94 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 92 def by_login(login) staffs.where(Sequel[email: login] | Sequel[phone: login]).one end |
#count ⇒ Integer
Returns the total number of staffs in the database.
56 57 58 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 56 def count staffs.count end |
#exists?(conditions) ⇒ Boolean
Checks if a bid exists based on the provided conditions.
100 101 102 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 100 def exists?(conditions) staffs.exist?(conditions) end |
#query(conditions) ⇒ AuctionFunCore::Relations::Staff
Constructs SQL conditions for querying staffs in the database.
64 65 66 |
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 64 def query(conditions) staffs.where(conditions) end |