summaryrefslogtreecommitdiff
path: root/api/database/models.go
blob: a6e76c5bca21bc506f1a1855d7787bbc1af7a358 (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
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"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}