如何在GORM中使用从BOM到Part的两个外键来实现特定的Part / BOM设计?

Here's a picture of a generic Bill of Materials.

Generic BOM (ignore supplier portion)

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 
}
  1. How do I indicate to GORM that Bom has two foreign keys into Part?
  2. How do I furnish the slices in Part from Bom?