1
0
Fork 0
empact/db/user.go

22 lines
501 B
Go

package db
import "time"
type User struct {
Login string `json:"login"`
Name string `json:"name"`
ID uint64 `json:"id"`
AvatarURL string `json:"avatar_url" db:"avatar_url"`
}
const saveUserQuery = `
insert into users (login, name, id, avatar_url)
values (:login, :name, :id, :avatar_url)
on duplicate key update
login=values(login), name=values(name), avatar_url=values(avatar_url)`
func (u *User) Save() {
defer measure("SaveUser", time.Now())
mustExecN(saveUserQuery, u)
}