/
models.go
107 lines (102 loc) · 2.54 KB
/
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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package design
import (
"github.com/goadesign/gorma"
. "github.com/goadesign/gorma/dsl"
)
var sg = StorageGroup("Congo Storage", func() {
Description("This is the global storage group")
Store("postgres", gorma.Postgres, func() {
Description("This is the postgres relational store")
Model("User", func() {
BuildsFrom(func() {
Payload("user", "create")
Payload("user", "update")
Payload("adminuser", "create")
Payload("adminuser", "update")
})
RendersTo(User)
Description("This is the User model")
BelongsTo("Tenant")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the ID PK field")
})
Field("first_name", gorma.String, func() {
Alias("firstname")
})
Field("last_name", gorma.String, func() {
Alias("lastname")
})
Field("href", gorma.String)
})
Model("Tenant", func() {
BuildsFrom(func() {
Payload("tenant", "create")
Payload("tenant", "update")
})
RendersTo(Tenant)
Description("This is the Tenant model")
HasMany("users", "User")
HasMany("events", "Event")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the ID PK field")
})
})
Model("Series", func() {
BuildsFrom(func() {
Payload("series", "create")
Payload("series", "update")
})
RendersTo(Series)
BelongsTo("Tenant")
Description("This is the Series model")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the ID PK field")
})
})
Model("Event", func() {
BuildsFrom(func() {
Payload("event", "create")
Payload("event", "update")
})
RendersTo(Event)
BelongsTo("Tenant")
HasMany("speakers", "Speaker")
HasMany("presentations", "Presentation")
Description("This is the Event model")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the ID PK field")
})
})
Model("Speaker", func() {
BuildsFrom(func() {
Payload("speaker", "create")
Payload("speaker", "update")
})
RendersTo(Speaker)
BelongsTo("Event")
Description("This is the Speaker model")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the ID PK field")
})
})
Model("Presentation", func() {
BuildsFrom(func() {
Payload("presentation", "create")
Payload("presentation", "update")
})
RendersTo(Presentation)
BelongsTo("Event")
BelongsTo("Speaker")
Description("This is the presentation model")
Field("id", gorma.Integer, func() {
PrimaryKey()
Description("This is the ID PK field")
})
})
})
})