mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 13:17:42 +00:00
fix account upsert
This commit is contained in:
parent
d0cf4e74d0
commit
33b3af6584
1 changed files with 7 additions and 2 deletions
|
@ -27,10 +27,15 @@ type AccountModel struct {
|
|||
func (am *AccountModel) Upsert(a *Account) error {
|
||||
query := `
|
||||
INSERT INTO accounts (username, account_id, access_token, refresh_token, expires_at, last_message_id, device_count, last_checked_at)
|
||||
VALUES ($1, $2, $3, $4, '', 0, 0)
|
||||
VALUES ($1, $2, $3, $4, $5, '', 0, 0)
|
||||
ON CONFLICT(username)
|
||||
DO
|
||||
UPDATE SET access_token = $2, refresh_token = $3, expires_at = $4, last_message_id = $5, last_checked_at = $6
|
||||
UPDATE SET
|
||||
access_token = $3,
|
||||
refresh_token = $4,
|
||||
expires_at = $5,
|
||||
last_message_id = $6,
|
||||
last_checked_at = $7
|
||||
RETURNING id`
|
||||
|
||||
args := []interface{}{a.NormalizedUsername(), a.AccountID, a.AccessToken, a.RefreshToken, a.ExpiresAt, a.LastMessageID, a.LastCheckedAt}
|
||||
|
|
Loading…
Reference in a new issue