-
Notifications
You must be signed in to change notification settings - Fork 35
/
definitions.go
170 lines (153 loc) · 4.98 KB
/
definitions.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package gorma
import (
"github.com/goadesign/goa/design"
"github.com/goadesign/goa/dslengine"
)
// RelationalStorageType is the type of database.
type RelationalStorageType string
// FieldType is the storage data type for a database field.
type FieldType string
// StorageGroupDefinition is the parent configuration structure for Gorma definitions.
type StorageGroupDefinition struct {
dslengine.Definition
DefinitionDSL func()
Name string
Description string
RelationalStores map[string]*RelationalStoreDefinition
}
// RelationalStoreDefinition is the parent configuration structure for Gorm relational model definitions.
type RelationalStoreDefinition struct {
dslengine.Definition
DefinitionDSL func()
Name string
Description string
Parent *StorageGroupDefinition
Type RelationalStorageType
RelationalModels map[string]*RelationalModelDefinition
NoAutoIDFields bool
NoAutoTimestamps bool
NoAutoSoftDelete bool
}
// RelationalModelDefinition implements the storage of a domain model into a
// table in a relational database.
type RelationalModelDefinition struct {
dslengine.Definition
*design.UserTypeDefinition
DefinitionDSL func()
ModelName string
Description string
GoaType *design.MediaTypeDefinition
Parent *RelationalStoreDefinition
BuiltFrom map[string]*design.UserTypeDefinition
BuildSources []*BuildSource
RenderTo map[string]*design.MediaTypeDefinition
BelongsTo map[string]*RelationalModelDefinition
HasMany map[string]*RelationalModelDefinition
HasOne map[string]*RelationalModelDefinition
ManyToMany map[string]*ManyToManyDefinition
Alias string // gorm:tablename
Cached bool
CacheDuration int
Roler bool
DynamicTableName bool
SQLTag string
RelationalFields map[string]*RelationalFieldDefinition
PrimaryKeys []*RelationalFieldDefinition
many2many []string
}
// BuildSource stores the BuildsFrom sources
// for parsing.
type BuildSource struct {
dslengine.Definition
DefinitionDSL func()
Parent *RelationalModelDefinition
BuildSourceName string
}
// MapDefinition represents field mapping to and from
// Gorma models.
type MapDefinition struct {
RemoteType *design.UserTypeDefinition
RemoteField string
}
// MediaTypeAdapterDefinition represents the transformation of a
// Goa media type into a Gorma Model.
//
// Unimplemented at this time.
type MediaTypeAdapterDefinition struct {
dslengine.Definition
DefinitionDSL func()
Name string
Description string
Left *design.MediaTypeDefinition
Right *RelationalModelDefinition
}
// UserTypeAdapterDefinition represents the transformation of a Goa
// user type into a Gorma Model.
//
// Unimplemented at this time.
type UserTypeAdapterDefinition struct {
dslengine.Definition
DefinitionDSL func()
Name string
Description string
Left *RelationalModelDefinition
Right *RelationalModelDefinition
}
// PayloadAdapterDefinition represents the transformation of a Goa
// Payload (which is really a UserTypeDefinition)
// into a Gorma model.
//
// Unimplemented at this time.
type PayloadAdapterDefinition struct {
dslengine.Definition
DefinitionDSL func()
Name string
Description string
Left *design.UserTypeDefinition
Right *RelationalModelDefinition
}
// RelationalFieldDefinition represents
// a field in a relational database.
type RelationalFieldDefinition struct {
dslengine.Definition
DefinitionDSL func()
Parent *RelationalModelDefinition
a *design.AttributeDefinition
FieldName string
TableName string
Datatype FieldType
SQLTag string
DatabaseFieldName string // gorm:column
Description string
Nullable bool
PrimaryKey bool
Timestamp bool
Size int // string field size
BelongsTo string
HasOne string
HasMany string
Many2Many string
Mappings map[string]*MapDefinition
}
// ManyToManyDefinition stores information about a ManyToMany
// relationship between two domain objects.
type ManyToManyDefinition struct {
dslengine.Definition
DefinitionDSL func()
Left *RelationalModelDefinition
Right *RelationalModelDefinition
RelationshipName string // ??
DatabaseField string
}
// StoreIterator is a function that iterates over Relational Stores in a
// StorageGroup.
type StoreIterator func(m *RelationalStoreDefinition) error
// ModelIterator is a function that iterates over Models in a
// RelationalStore.
type ModelIterator func(m *RelationalModelDefinition) error
// FieldIterator is a function that iterates over Fields
// in a RelationalModel.
type FieldIterator func(m *RelationalFieldDefinition) error
// BuildSourceIterator is a function that iterates over Fields
// in a RelationalModel.
type BuildSourceIterator func(m *BuildSource) error