Compare commits
3 Commits
1fb45f8c4a
...
09215bc616
Author | SHA1 | Date |
---|---|---|
simponic | 09215bc616 | |
Ezri Brimhall | 161dcbad20 | |
Ezri Brimhall | 76fb42a61e |
|
@ -50,12 +50,7 @@ func GetUser(dbConn *sql.DB, id string) (*User, error) {
|
|||
func FindOrSaveUser(dbConn *sql.DB, user *User) (*User, error) {
|
||||
log.Println("finding or saving user", user.ID)
|
||||
|
||||
_, err := dbConn.Exec(`INSERT OR IGNORE INTO users (id, mail, username, display_name) VALUES (?, ?, ?, ?);`, user.ID, user.Mail, user.Username, user.DisplayName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = dbConn.Exec(`UPDATE users SET mail = ?, username = ?, display_name = ? WHERE id = ?;`, user.Mail, user.Username, user.DisplayName, user.ID)
|
||||
_, err := dbConn.Exec(`INSERT INTO users (id, mail, username, display_name) VALUES (?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET mail = excluded.mail, username = excluded.username, display_name = excluded.display_name;`, user.ID, user.Mail, user.Username, user.DisplayName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue