beerpong-elo/internal/model/gameResult.go

27 lines
483 B
Go
Raw Normal View History

2025-02-02 15:11:35 +01:00
package model
import "fmt"
type GameResultID string
type GameResult struct {
ID GameResultID
Game GameID
Player PlayerID
StartElo int
EndElo int
}
func (id *GameResultID) Scan(src any) error {
switch v := src.(type) {
case int64:
*id = GameResultID(fmt.Sprintf("%d", v)) // Convert int64 to string and assign it
return nil
case string:
*id = GameResultID(v)
return nil
default:
return fmt.Errorf("unsupported type %T for GameResultID", src)
}
}