refactored for maintainability
This commit is contained in:
@@ -87,25 +87,3 @@ func GetSeason(ctx context.Context, tx bun.Tx, shortname string) (*Season, error
|
||||
}
|
||||
return season, nil
|
||||
}
|
||||
|
||||
func IsSeasonNameUnique(ctx context.Context, tx bun.Tx, name string) (bool, error) {
|
||||
count, err := tx.NewSelect().
|
||||
Model((*Season)(nil)).
|
||||
Where("name = ?", name).
|
||||
Count(ctx)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "tx.NewSelect")
|
||||
}
|
||||
return count == 0, nil
|
||||
}
|
||||
|
||||
func IsSeasonShortNameUnique(ctx context.Context, tx bun.Tx, shortname string) (bool, error) {
|
||||
count, err := tx.NewSelect().
|
||||
Model((*Season)(nil)).
|
||||
Where("short_name = ?", shortname).
|
||||
Count(ctx)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "tx.NewSelect")
|
||||
}
|
||||
return count == 0, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user