我想将Coins结构的地址设置为Accounts结构的外键地址,如何在beego orm中设置?
type Coins struct {
Id int `orm:"auto"`
Address string `orm:"rel(fk);on_delete(cascade);on_update(cascade);index" json:"address"`
Symbol string `json:"symbol"`
Amount float64 `orm:"digits(64);decimals(6)" json:"amount"`
CreatedAt time.Time `orm:"auto_now_add;type(datetime)"`
UpdatedAt time.Time `orm:"auto_now_add;type(datetime)"`
}
type Accounts struct {
Id int `orm:"auto"`
Address string `orm:"index;unique" json:"address"`
Type string `json:"type"`
}发布于 2020-04-17 19:37:52
看,如果这行得通:
type Coins struct {
Id int `orm:"auto"`
Accouts *Accounts `orm:"rel(fk)"`
Address string `orm:"pk;auto;on_delete(cascade);on_update(cascade);index" json:"address"`
Symbol string `json:"symbol"`
Amount float64 `orm:"digits(64);decimals(6)" json:"amount"`
CreatedAt time.Time `orm:"auto_now_add;type(datetime)"`
UpdatedAt time.Time `orm:"auto_now_add;type(datetime)"`
}
type Accounts struct {
Id int `orm:"pk;auto"`
Address string `orm:"index;unique" json:"address"`
Type string `json:"type"`
}https://stackoverflow.com/questions/61268327
复制相似问题