type (
Languages struct {
ID uint `json:"id"`
Name string `json:"name"`
}
User struct {
ID uint `json:"id"`
Name string `json:"name"`
Languages []*Languages `json:"languages"`
}
)
user := &User{Name: "jinzhu", Languages: []*Languages{
{ID:1},
{ID:2},
}}
db.Create(user)
db.Session(&gorm.Session{FullSaveAssociations: false}).Create(user)
以上会多一句:
INSERT INTO `languages ` (`name`,`id`) VALUES ('',1),('',2) ON DUPLICATE KEY UPDATE `id`=`id`
Your Question
以上会多一句:
不能跳过吗?