Skip to content

Relationships

Iridium support relationships in its form and table components based off your underlying model and the name associated with your components.

To access data through a relationship, you can use dot notation in your field names

Relationships

One-to-One

A one-to-one relationship

go
type User struct {
    ID           uint          `gorm:"primaryKey"`
    Name         string
    Appointments []Appointment `gorm:"foreignKey:UserID"`
}

type Appointment struct {
    ID       uint      `gorm:"primaryKey"`
    UserID   uint      // foreign key
    Name     string
    Date     time.Time
    Location string
}

Accessing in a form component for the user model

go
FormInput("Appointments[0].Name") // Will render the fist appointment's name

One-to-Many

Many-to-Many

Released under the MIT License.