I am having trouble making queries in GORM, like joins

Viewed 34
    type Books_model struct {
        // gorm.Model
        Book_id      string       `json:"book_id" gorm:"primarykey"`
        Title        string       `json:"title"`
        Author       string       `json:"author"`
        Gender       string       `json:"gender"`
        Publisher    string       `json:"publisher"`
        Country      string       `json:"country"`
        Rating_model Rating_model `gorm:"foreignKey:Books_rating_id;AssociationForeignKey:Books_rating_id"`
        // ;AssociationForeignKey:Books_rating_id
        Reviews_model Reviews_model `gorm:"foreignKey:Books_model_id;AssociationKey:Books_model_id"`
    }

    type Rating_model struct {
        gorm.Model
        Books_rating_id string `json:"books_rating_id" `
        `gorm:"foreignKey:book_id;references:Book_id"`
        Rating string `json:"rating"`
    }


 type Reviews_model struct {
        gorm.Model
        Ret_id         string `json:"ret_id"`
        Books_model_id string `json:"books_model_id"`
        Review         string `json:"review"`
    }

############################## My problem is that i have made foreign keys and i have make joins to combine the tables like book id 3 has rating of 4 and review is this, but i am trying no query is working,Gorm is really hard to understand.

0 Answers
Related