# frozen_string_literal: true require 'rom-repository' module EuchreCamp module Repositories class PartnershipGames < ::EuchreCamp::Repository[:partnership_games] commands :create, update: :by_pk, delete: :by_pk def by_player(player_id) partnership_games.where( Sequel.|({ player_1_id: player_id }, { player_2_id: player_id }) ).to_a end def by_match(match_id) partnership_games.where(match_id: match_id).to_a end def by_partnership(player_1_id, player_2_id) partnership_games.where( Sequel.|( { player_1_id: player_1_id, player_2_id: player_2_id }, { player_1_id: player_2_id, player_2_id: player_1_id } ) ).to_a end end end end