Last active
January 19, 2020 13:41
-
-
Save yutakahashi114/26217937503b3d1b4bbc6f62783d2586 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
type user struct { | |
ID uint64 `xorm:"autoincr"` | |
FirstName string | |
LastName string | |
FirstNameKana string | |
LastNameKana string | |
Version uint64 `xorm:"version"` | |
CreatedAt time.Time `xorm:"created"` | |
UpdatedAt time.Time `xorm:"updated"` | |
DeletedAt time.Time `xorm:"deleted"` | |
} | |
func (user) TableName() string { | |
return "users" | |
} | |
func create(engine *xorm.Engine) { | |
u := user{ | |
FirstName: "太郎", | |
LastName: "テスト", | |
} | |
affected, err := engine.Insert(&u) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
if affected == 0 { | |
log.Println("No Affected") | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment