Created
January 19, 2020 13:24
-
-
Save yutakahashi114/7f8f0af1b27d5f2fda446aa7b1e6227a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u := user{} | |
has, err := engine. | |
Where("id = ?", id). | |
Get(&u) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
if !has { | |
log.Println("Not Found") | |
return | |
} | |
u.FirstName = "太郎更新" | |
u.LastName = "テスト更新" | |
u.FirstNameKana = "タロウコウシン" | |
affected, err = engine. | |
Where("id = ?", id). | |
Update(&u) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
if affected == 0 { | |
log.Println("Not Found") | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment