Format token save query
This commit is contained in:
parent
60877e5393
commit
22fca9f4e1
13
db/token.go
13
db/token.go
|
@ -14,13 +14,14 @@ type Token struct {
|
||||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveTokenQuery = `
|
func (t *Token) Save() {
|
||||||
|
defer measure("SaveToken", time.Now())
|
||||||
|
mustExecN(`
|
||||||
insert into tokens (user, token, quota, remaining, reset_at, created_at)
|
insert into tokens (user, token, quota, remaining, reset_at, created_at)
|
||||||
values (:user, :token, :quota, :remaining, :reset_at, now())
|
values (:user, :token, :quota, :remaining, :reset_at, now())
|
||||||
on duplicate key update
|
on duplicate key update
|
||||||
quota = values(quota), remaining = values(remaining), reset_at = values(reset_at)`
|
quota = values(quota),
|
||||||
|
remaining = values(remaining),
|
||||||
func (t *Token) Save() {
|
reset_at = values(reset_at)
|
||||||
defer measure("SaveToken", time.Now())
|
`, t)
|
||||||
mustExecN(saveTokenQuery, t)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue