summaryrefslogtreecommitdiff
path: root/internal/api/database/models.go
blob: 4acbca50f79805174c047fb7ed638b120ccd7874 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package database

import "time"

type User struct {
	ID        int       `json:"id"`
	Username  string    `json:"username"`
	Password  string    `json:"password"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Game struct {
	ID         int       `json:"id"`
	Player1ID  int       `json:"-"`
	Player1    User      `gorm:"foreignKey:Player1ID" json:"player1"`
	Player2ID  *int      `json:"-"`
	Player2    *User     `gorm:"foreignKey:Player2ID;null" json:"player2"`
	Name       string    `json:"name"`
	IP1        string    `json:"ip1"`
	IP2        string    `json:"ip2"`
	Outcome    string    `json:"outcome"`
	LastPlayer int       `json:"last_player"` // Last player entered in game
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}