-
Notifications
You must be signed in to change notification settings - Fork 0
/
stuff
20 lines (19 loc) · 1.05 KB
/
stuff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
type User struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key"`
Name string `gorm:"type:varchar(100);not null"`
Username string `gorm:"type:varchar(100);uniqueIndex;not null"`
Email string `gorm:"type:varchar(100);uniqueIndex;not null"`
Password string `gorm:"type:varchar(100);not null"`
Role *string `gorm:"type:varchar(50);default:'user';not null"`
Photo *string `gorm:"not null;default:'default.png'"`
Verified *bool `gorm:"not null;default:false"`
Followers []*User `gorm:"many2many:user_relationships;association_jointable_foreignkey:follower_id"`
Following []*User `gorm:"many2many:user_relationships;association_jointable_foreignkey:following_id"`
CreatedAt *time.Time `gorm:"not null;default:now()"`
UpdatedAt *time.Time `gorm:"not null;default:now()"`
}
type UserRelationship struct {
ID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primary_key"`
FollowerID uuid.UUID `gorm:"type:uuid;not null"`
FollowingID uuid.UUID `gorm:"type:uuid;not null"`
}