func Season(row MultiScanner) (*model.Season, error) { //s.id, s.name, s.start_date, s.end_date, s.created, s.modified, l.id, l.name, l.sport, l.created, l.modified var season model.Season var league model.League err := row.Scan(&season.ID, &league.ID, &season.Name, &season.StartDate, &season.EndDate, &season.Created, &season.Modified) if err != nil { return nil, err } season.League = &league return &season, nil }
func (repo *PgRepository) CreateSeason(season *model.Season) error { err := season.Validate(repo) if err != nil { return err } t := time.Now() var id int err = repo.manager.db.QueryRow(`INSERT INTO season(league_id, name, start_date, end_date, created, modified) VALUES($1, $2, $3, $4, $5, $6) RETURNING id`, season.League.ID, season.Name, season.StartDate, season.EndDate, t, t).Scan(&id) if err != nil { return err } season.ID = id season.Created = t season.Modified = t return nil }