Class: AuctionFunCore::Repos::StaffContext::StaffRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/auction_fun_core/repos/staff_context/staff_repository.rb

Overview

SQL repository for staffs.

Instance Method Summary collapse

Instance Method Details

#allArray<ROM::Struct::Staff>, []

Returns all staffs in database.



15
16
17
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 15

def all
  staffs.to_a
end

#by_id(id) ⇒ ROM::Struct::Staff?

Search staff in database by primary key.



35
36
37
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 35

def by_id(id)
  staffs.by_pk(id).one
end

#by_id!(id) ⇒ ROM::Struct::Auction

Search staffs in database by primary key.

Raises:

  • (ROM::TupleCountMismatchError)

    if not found on database



43
44
45
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 43

def by_id!(id)
  staffs.by_pk(id).one!
end

#by_login(login) ⇒ ROM::Struct::Staff?

Search staff in database by email of phone keys.



50
51
52
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 50

def ()
  staffs.where(Sequel[email: ] | Sequel[phone: ]).one
end

#countInteger

Returns the total number of staffs in database.



21
22
23
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 21

def count
  staffs.count
end

#exists?(conditions) ⇒ true, false

Checks if it returns any staff given one or more conditions.



58
59
60
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 58

def exists?(conditions)
  staffs.exist?(conditions)
end

#query(conditions) ⇒ AuctionFunCore::Relations::Staffs

Mount SQL conditions in query for search in database.



28
29
30
# File 'lib/auction_fun_core/repos/staff_context/staff_repository.rb', line 28

def query(conditions)
  staffs.where(conditions)
end