Should Gorm write one-to-many relationship, has many and belongs to both set or just write one side?

do you want to set both, has many and belongs to for Gorm"s one-to-many relationships or just write on one side?
it seems that the official website only writes on one side, not on both sides. http://gorm.io/zh_CN/docs/has.

clipboard.png

Jan.29,2022

personally, I don't think it's necessary to use these, which will make the whole look messy, so just make a normal query.


belongs to is not a concept. You use belongs to to associate two struct,. You insert a table into the database as an operation. You can see it over and over again, or you don't need belongs to

to understand it this way.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e446ea-44ab7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e446ea-44ab7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?