forked from go-rel/rel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rel_test.go
69 lines (57 loc) · 1023 Bytes
/
rel_test.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package rel
import (
"time"
)
type Status string
type User struct {
ID int
Name string
Age int
Transactions []Transaction `ref:"id" fk:"user_id"`
Address Address
UserRoles []UserRole
CreatedAt time.Time
UpdatedAt time.Time
}
type Transaction struct {
ID int
Item string
Status Status
BuyerID int `db:"user_id"`
Buyer User `ref:"user_id" fk:"id"`
AddressID int
Address Address
Histories *[]History
}
type History struct {
ID int
TransactionID int
}
type Notes string
func (n Notes) Equal(other interface{}) bool {
if o, ok := other.(Notes); ok {
return n == o
}
return false
}
type Address struct {
ID int
UserID *int
User *User
Street string
Notes Notes
DeletedAt *time.Time
}
type Owner struct {
User *User
UserID *int
}
type Role struct {
ID int
Name string
UserRoles []UserRole
}
type UserRole struct {
UserID int `db:",primary"`
RoleID int `db:",primary"`
}