package models // BookWork represents the many-to-many relationship between books and works type BookWork struct { BaseModel BookID uint Book *Book `gorm:"foreignKey:BookID"` WorkID uint Work *Work `gorm:"foreignKey:WorkID"` Order int `gorm:"default:0"` // For ordering works in books } // AuthorCountry represents the many-to-many relationship between authors and countries type AuthorCountry struct { BaseModel AuthorID uint Author *Author `gorm:"foreignKey:AuthorID"` CountryID uint Country *Country `gorm:"foreignKey:CountryID"` } // WorkAuthor represents authorship with role and order for a work type WorkAuthor struct { BaseModel WorkID uint Work *Work `gorm:"foreignKey:WorkID"` AuthorID uint Author *Author `gorm:"foreignKey:AuthorID"` Role string `gorm:"size:50;default:'author'"` Ordinal int `gorm:"default:0"` } // BookAuthor represents book-level contributor role and order type BookAuthor struct { BaseModel BookID uint Book *Book `gorm:"foreignKey:BookID"` AuthorID uint Author *Author `gorm:"foreignKey:AuthorID"` Role string `gorm:"size:50;default:'author'"` Ordinal int `gorm:"default:0"` }