27 lines
483 B
Go
27 lines
483 B
Go
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)
|
|
}
|
|
}
|