-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
34 lines (29 loc) · 848 Bytes
/
models.go
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
27
28
29
30
31
32
33
34
package database
import (
"time"
_ "github.com/jinzhu/gorm/dialects/mysql"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
// BaseModel declares base fields that are to be used on all models
type BaseModel struct {
ID uint `gorm:"primary_key;"`
CreatedAt time.Time
UpdatedAt time.Time
}
// Team represents a team of developers
type Team struct {
BaseModel
Name string `gorm:"size:128;not null;unique_index;"`
Email string `gorm:"size:64;"`
URL string `gorm:"size:1024;"`
Users []User `gorm:"many2many:teams_users;"`
}
// User represents a developer
type User struct {
BaseModel
Name string `gorm:"size:128;not null;unique_index;"`
Email string `gorm:"size:64;not null;unique_index;"`
Password string `gorm:"size:60;not null;"`
IsAdmin bool `gorm:"not null;"`
Teams []Team `gorm:"many2many:teams_users;"`
}