Files
csgowtfd/ent/schema/match.go

45 lines
1.0 KiB
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Match holds the schema definition for the Match entity.
type Match struct {
ent.Schema
}
// Fields of the Match.
func (Match) Fields() []ent.Field {
return []ent.Field{
field.Uint64("id").Unique().Immutable().StructTag(`json:"match_id,string"`),
field.String("share_code"),
field.String("map").Optional(),
field.Time("date"),
field.Int("score_team_a"),
field.Int("score_team_b"),
field.String("replay_url").Optional().StructTag(`json:"-"`),
field.Int("duration"),
field.Int("match_result"),
field.Int("max_rounds"),
field.Bool("demo_parsed").Default(false),
field.JSON("eco", struct {
Rounds []*struct {
Team int `json:"team"`
Bank int `json:"bank"`
Equipment int `json:"equipment"`
} `json:"rounds"`
}{}).Optional(),
}
}
// Edges of the Match.
func (Match) Edges() []ent.Edge {
return []ent.Edge{
edge.To("stats", Stats.Type),
edge.From("players", Player.Type).Ref("matches"),
}
}