Here's a picture of a generic Bill of Materials.
How does one implement the join table named "BOM" above using GORM and its tags? (Ignore the supplier tables.)
type Part struct {
gorm.Model
Parents []Part
Children []Part
}
Update
The goal is to query for a part, P, and be able to show all the parts that P is used in and all the parts P uses. The ER diagram designs this kind of solution in the database. I've built solutions in SQL and other languages to do this. Now I'd like to use GORM to provide it.
Because Quantity is in the join table, there will have to be a declared struct rather than a GORM generated join table. Something like this:
type Bom struct {
Parent Part
Child Part
Quantity int
}