Given the following one-to-many
relationship (One Receipt
has many LineItem
's), I would like to map the Price
field from the Receipt
table into the Price
field of LineItem
table (for each LineItem
in Product
).
Receipt Schema
type Product struct {
ID uint `json:"id"`
TotalPrice float64 `json:"total"`
LineItems []LineItem `json:"lineItems"`
}
LineItem Schema
type LineItem struct {
ID uint `json:"id"`
ProductID uint `json:"productID"`
Price float64 `json:"price"`
}
I'm currently using gorm, an ORM for Go, but I can't find the functionality to support what I'm looking for.