File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,24 @@ type Paper struct {
19
19
Abstract string `json:"abstract" gorm:"not null;type:text"`
20
20
AbsUrl string `json:"url" gorm:"not null"`
21
21
TarballUrl string `json:"tarball_url" gorm:"not null"`
22
- Macros string `json:"macros" gorm:"type:text "`
22
+ Macros [] Macro `json:"macros" gorm:"association_save_reference:true;foreignkey:PaperID "`
23
23
Equations []Equation `json:"equations" gorm:"association_save_reference:true;foreignkey:PaperID"`
24
24
}
25
25
26
26
func (Paper ) TableName () string {
27
27
return "papers"
28
28
}
29
29
30
+ type Macro struct {
31
+ Expression string `json:"expression" gorm:"not null;type:varchar(2000)"`
32
+ Command string `json:"command" gorm:"not null;type:varchar(100)"`
33
+ PaperID uint `json:"paper_id" gorm:"not null"`
34
+ }
35
+
36
+ func (Macro ) TableName () string {
37
+ return "macros"
38
+ }
39
+
30
40
type Author struct {
31
41
Model
32
42
Name string `json:"name" gorm:not null`
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ func initApp(db *gorm.DB) {
28
28
& controllers.Paper {},
29
29
& controllers.Equation {},
30
30
& controllers.Author {},
31
+ & controllers.Macro {},
31
32
}
32
33
for _ , model := range models {
33
34
db .AutoMigrate (model )
You can’t perform that action at this time.
0 commit comments