Why gorm has many self refrence not working for me
type Comment struct {
gorm.Model
Text string `sql:"type:text;"`
Comments []Comment `gorm:"foreignkey:ID;associatdion_foreignkey:ParentID"`
ParentID uint
PostID uint
UserID uint
}
this is the error:
invalid association []
this is my code to give result
var comments Comment
var child []Comment
db.First(&comments, 3)
db.Model(&comments).Related(&child)
fmt.Println("comments: ", child)