I have the following structs:
type Project struct {
gorm.Model
Title string
Description string
Skills []Skill `gorm:"many2many:project_skills;"`
}
type Skill struct {
gorm.Model
Name string
}
this is how I create the project (and then Gorm creates automatically the skills):
create := rs.Db().Create(&project)
there is a simple way through gorm to create skills only if there is no entry with the same name?, and if there is, return the existing one. so I will get an array of skills, the new one, and old ones. I hope I managed to explain myself.