2015-03-05 15:04:44 +00:00
|
|
|
package db
|
|
|
|
|
2015-03-06 10:00:04 +00:00
|
|
|
type User struct {
|
|
|
|
Login string `json:"login"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
ID int64 `json:"id"`
|
|
|
|
AvatarURL string `json:"avatar_url"`
|
|
|
|
}
|
2015-03-05 15:04:44 +00:00
|
|
|
|
2015-03-06 10:00:04 +00:00
|
|
|
const saveUserQuery = `
|
|
|
|
insert into users (login, name, id, avatar_url)
|
|
|
|
values (?, ?, ?, ?)
|
|
|
|
on duplicate key update
|
|
|
|
login=values(login), name=values(name), avatar_url=values(avatar_url)`
|
2015-03-05 15:04:44 +00:00
|
|
|
|
|
|
|
func (u *User) Save() {
|
2015-03-06 10:00:04 +00:00
|
|
|
conn.MustExec(saveUserQuery, u.Login, u.Name, u.ID, u.AvatarURL)
|
2015-03-05 15:04:44 +00:00
|
|
|
}
|