Esempio n. 1
0
func (repo *PgRepository) FindSeasonByID(id int) (*model.Season, error) {
	row := repo.manager.db.QueryRow(`SELECT s.id, s.league_id, s.name, s.start_date, s.end_date, s.created, s.modified
        FROM season s
        WHERE s.id = $1`, id)

	season, err := marshal.Season(row)
	if err != nil {
		return &model.Season{}, err
	}

	return season, nil
}
Esempio n. 2
0
func (repo *PgRepository) FindMostRecentSeasonByLeague(league *model.League) (*model.Season, error) {
	row := repo.manager.db.QueryRow(`SELECT s.id, s.league_id, s.name, s.start_date, s.end_date, s.created, s.modified
        FROM season s
        WHERE s.league_id = $1
        ORDER BY s.end_date DESC
        LIMIT 1`, league.ID)

	season, err := marshal.Season(row)
	if err != nil {
		return &model.Season{}, err
	}

	return season, err
}