mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Add update username method
This commit is contained in:
parent
626b7fa3e9
commit
7c2c993dc3
10 changed files with 82 additions and 9 deletions
|
@ -40,7 +40,7 @@ import (
|
|||
type AppDatabase interface {
|
||||
UserExists(uid string) (bool, error)
|
||||
GetUserID(name string) (string, error)
|
||||
SetName(name string) error
|
||||
UpdateUsername(uid, name string) error
|
||||
CreateUser(name string) (string, error)
|
||||
FollowUser(uid string, follow string) error
|
||||
UnfollowUser(uid string, unfollow string) error
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// Check if user exists
|
||||
func (db *appdbimpl) UserExists(uid string) (bool, error) {
|
||||
var name string
|
||||
err := db.c.QueryRow(`SELECT "name" FROM "users" WHERE "uid" = ?`, name).Scan(&name)
|
||||
err := db.c.QueryRow(`SELECT "name" FROM "users" WHERE "uid" = ?`, uid).Scan(&name)
|
||||
|
||||
if db_errors.EmptySet(err) {
|
||||
return false, nil
|
||||
|
@ -38,6 +38,12 @@ func (db *appdbimpl) CreateUser(name string) (string, error) {
|
|||
return uid.String(), err
|
||||
}
|
||||
|
||||
// Update username
|
||||
func (db *appdbimpl) UpdateUsername(uid string, name string) error {
|
||||
_, err := db.c.Exec(`UPDATE "users" SET "name" = ? WHERE "uid" = ?`, name, uid)
|
||||
return err
|
||||
}
|
||||
|
||||
// Follow a user
|
||||
func (db *appdbimpl) FollowUser(uid string, follow string) error {
|
||||
_, err := db.c.Exec(`INSERT INTO "follows" ("follower", "followed") VALUES (?, ?)`, uid, follow)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue