douri4459 2018-11-06 17:23
浏览 20

自引用模型中的额外列

I just started to use Gorm and I am encountering troubles to define a model.
I have succeeded in creating a join table by following the doc example for self-referencing model:

type User struct {
  gorm.Model
  Friends []*User `gorm:"many2many:friendships;association_jointable_foreignkey:friend_id"`
}

The problem is I want an extra column in my join table to know whether a friend is accepted or not. I have looked for an answer through the internet but the only answer that I found is this : https://github.com/jinzhu/gorm/issues/719#issuecomment-168485989 but I don't understand how I can adapt it in my case.
If anyone out there has any examples and/or solutions, I will be grateful. Thanks again !

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作