..
Viewing
models.go
23 lines (19 loc) • 606.0 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | package database
import (
"time"
"gorm.io/gorm"
)
type User struct {
gorm.Model
Username string `gorm:"uniqueIndex;not null" json:"username"`
Email string `gorm:"uniqueIndex;not null" json:"email"`
Password string `gorm:"not null" json:"-"`
JoinedAt time.Time `gorm:"autoCreateTime" json:"joined_at"`
}
type Session struct {
gorm.Model
UserID uint `gorm:"index;not null" json:"user_id"`
Token string `gorm:"uniqueIndex;not null" json:"token"`
ExpiresAt time.Time `gorm:"index;not null" json:"expires_at"`
User User `gorm:"foreignKey:UserID" json:"-"`
}
|
|