title: Increment struct value in Go
body: <p>I'm expecting to see the <code>visits</code> increment with every <code>GET</code> request to <code>/foo</code> but it remains as <code>1</code>. What am I doing wrong here?</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;log&quot;
  
      &quot;github.com/gofiber/fiber/v2&quot;
      &quot;gorm.io/driver/sqlite&quot;
      &quot;gorm.io/gorm&quot;
  )
  
  // Item model
  type Item struct {
      gorm.Model
      UID    int64  `gorm:&quot;primaryKey;autoIncrement&quot;`
      Name   string `gorm:&quot;index;not null&quot;`
      Visits int32  `gorm:&quot;default 0&quot;`
  }
  
  func main() {
      db, err := gorm.Open(sqlite.Open(&quot;test.db&quot;), &amp;gorm.Config{})
  
      if err != nil {
          panic(err)
      }
  
      db.AutoMigrate(&amp;Item{})
      db.Create(&amp;Item{
          Name: &quot;foo&quot;,
      })
  
      app := fiber.New(fiber.Config{})
  
      app.Get(&quot;/:name&quot;, func(c *fiber.Ctx) error {
          var i Item
          db.First(&amp;i, &quot;name = ?&quot;, c.Params(&quot;name&quot;))
  
          if i.Name == &quot;&quot; {
              return c.Status(fiber.StatusNotFound).JSON(&amp;fiber.Map{
                  &quot;message&quot;: &quot;Not found&quot;,
              })
          }
  
          db.Model(&amp;i).Update(&quot;visits&quot;, i.Visits+1)
          return c.JSON(i)
      })
  
      log.Println(&quot;Listening...&quot;)
      log.Fatal(app.Listen(&quot;:3000&quot;))
  }
  </code></pre>