title: Golang Gorm BackReference
body: <p>So I have two structs User and Company which are as follows</p>
  <pre><code>//Company
  type Company struct {
      Id                        int       `json:&quot;id&quot; gorm:&quot;primaryKey;autoIncrement;type:int&quot;`
      Poc_name                  string    `json:&quot;poc_name&quot; gorm:&quot;type:string;size:128;not null&quot;`
      Poc_title                 string    `json:&quot;poc_title&quot; gorm:&quot;type:string;size:255;not null&quot;`
      Poc_email                 string    `json:&quot;poc_email&quot; gorm:&quot;type:string;size:128;not null&quot;`
      Poc_phone                 string    `json:&quot;poc_phone&quot; gorm:&quot;type:string;size:128;not null&quot;`
      Default_driver_commission float32   `json:&quot;default_driver_commission&quot; gorm:&quot;type:float;default:12;not null&quot;`
      Mc_number                 string    `json:&quot;mc_number&quot; gorm:&quot;type:string;size:128;default:null&quot;`
      Us_dot_number             string    `json:&quot;us_dot_number&quot; gorm:&quot;type:string;size:128;default:null&quot;`
      Fk_user_id                int       `json:&quot;fk_user_id&quot; gorm:&quot;not null;type:int&quot;`
      Fk_user                   Users     `json:&quot;user&quot; gorm:&quot;foreignKey:Fk_user_id&quot;`
      Time_created              time.Time `json:&quot;time_created&quot; gorm:&quot;autoCreateTime;not null&quot;`
      Time_updated              time.Time `json:&quot;time_updated&quot; gorm:&quot;autoCreateTime;not null&quot;`
  }
  
  //User
  type Users struct {
      Id                  int       `json:&quot;id&quot; gorm:&quot;primaryKey;autoIncrement;type:int&quot;`
      Username            string    `json:&quot;username&quot; gorm:&quot;unique;not null;type:string;size:128&quot;`
      Email               string    `json:&quot;email&quot; gorm:&quot;unique;not null;type:string;size:128&quot;`
      Password            string    `gorm:&quot;not null;type:string;size:255&quot;`
      Phone               string    `json:&quot;phone&quot; gorm:&quot;not null;type:string;size:128&quot;`
      First_name          string    `json:&quot;first_name&quot; gorm:&quot;not null;type:string;size:128&quot;`
      Last_name           string    `json:&quot;last_name&quot; gorm:&quot;not null;type:string;size:128&quot;`
      Provider            string    `json:&quot;provider&quot; gorm:&quot;not null;type:string;size:128&quot;`
      Profile_picture_url string    `json:&quot;profile_picture_url&quot; gorm:&quot;type:text&quot;`
      Is_verified         bool      `json:&quot;is_verified&quot; gorm:&quot;default:true;not null&quot;`
      Stripe_id           string    `json:&quot;stripe_id&quot; gorm:&quot;not null;type:string;size:350&quot;`
      Fcm_token           string    `json:&quot;fcm_token&quot; gorm:&quot;not null;type:string;size:350&quot;`
      Web_fcm_token       string    `json:&quot;web_fcm_token&quot; gorm:&quot;not null;type:string;size:350&quot;`
      Hour_format_12      bool      `json:&quot;hour_format_12&quot; gorm:&quot;not null;default:false&quot;`
      Temp_in_centi       bool      `json:&quot;temp_in_centi&quot; gorm:&quot;not null;default:false&quot;`
      Map_pref            string    `json:&quot;map_pref&quot; gorm:&quot;not null;type:string;size:350&quot;`
      Time_created        time.Time `json:&quot;time_created&quot; gorm:&quot;autoCreateTime;not null&quot;`
      Time_updated        time.Time `json:&quot;time_updated&quot; gorm:&quot;autoCreateTime;not null&quot;`
      User_type           int       `json:&quot;user_type&quot; gorm:&quot;not null&quot;`
      Address_id          int       `json:&quot;address_id&quot; gorm:&quot;not null&quot;`
      Fk_address          Address   `json:&quot;address&quot; gorm:&quot;foreignKey:Address_id&quot;`
      
  }
  </code></pre>
  <p>And this is my api call</p>
  <pre><code>func GetUserById(c *fiber.Ctx) error {
      id, err := c.ParamsInt(&quot;id&quot;)
  
      // var user models.Company
      var user models.Users
  
      if err != nil {
          return c.Status(400).JSON(&quot;Please Ensure that :id is an integer&quot;)
      }
  
      // database.Database.Db.Preload(&quot;Fk_user.Fk_address&quot;).Where(&quot;Fk_user_id = ?&quot;, id).Find(&amp;user)
      database.Database.Db.Preload(&quot;Fk_address&quot;).Find(&amp;user, id)
  
      if user.Id == 0 {
          return c.Status(404).JSON(&quot;User Does Not Exists&quot;)
      }
  
      // log.Fatalln(responseuser.Fk_address)
  
      return c.Status(200).JSON(&amp;user)
  
  }
  </code></pre>
  <p>How can I access the company object from the user object. Previously we using Flask and SQAlchemy and it was made possible by back_ref. Is there anything similar in Gorm and Fiber ? thanks</p>