使用gorm建立多對(duì)多關(guān)系時(shí)败晴,發(fā)現(xiàn)沒(méi)有成功雁歌,報(bào)錯(cuò):Error 1075: Incorrect table definition; there can be only one auto column and it must be defined as a key
查看代碼發(fā)現(xiàn)在台妆,我的兩個(gè)主表的ID都寫(xiě)了type:int(11) unsigned auto_increment;
我使用的是mysql,不能有多個(gè)自增長(zhǎng)的列。
參考gorm.Model的寫(xiě)法,于是把ID改`gorm:"primary_key;comment:記錄ID;"`
問(wèn)題就解決了勇哗。