My foreign key column name doesn't match the folder it points to. I can't work out what to pass to preload.

Is it the struct name? the table? the model? the foreign key column? the struct member that holds the foreign key? something in gorm tags?

I have two models: File and Folder. File.ParentFolder points to Folder (File.ParentFolderID -> Folder.ID)

I've tried .Preload("Folder").Find(&file) and .Preload("ParentFolder").Find(&file) and neither result in form loading that File.Folder data for me.

type File struct {
    BasicModel     // <-- UUID has PrimaryKeys, otherwise the same as gorm.Model
    Name           string
    ParentFolderID string  `gorm:"column:parentfolderid"`
    ParentFolder   *Folder `gorm:"foreignKey:ParentFolderID"`
    InTrash        bool
}

type Folder struct {
    BasicModel
    Name           string
    ParentFolderID *string `gorm:"default:null"`
    ParentFolder   *Folder `gorm:"foreignKey:ParentFolderID"`
    InTrash        bool
}

The document you expected this should be explained

https://gorm.io/docs/preload.html

Expected answer

What to pass to .Preload() and maybe also .Join() . Table name? column name? Model name? Foreign key name?

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking