I'm trying to follow Gorm's documentation to create a generated field, defined by a function:
type Foo struct {
ID int64 `json:"id"`
AmountOfBars string `json:"amount_of_bars" gorm:"default:amount_of_bars()"`
}
type RelatedBar struct {
FooId int64 `json:"foo_id"`
}
However, I don't understand where and how to define amount_of_bars, so I'll be able to return the amount of the RelatedBar related rows.