summaryrefslogtreecommitdiff
path: root/db/user.go
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-02 14:15:25 -0500
committersanine-a <sanine.not@pm.me>2023-05-02 14:15:25 -0500
commite365e8c2fd4e3a595c696849734236008fc67e1f (patch)
tree072316b0ff99dd94d698090b6ad3b02ab7852d95 /db/user.go
parent9fe48ae66c2cc8d6b46e44ae35e9447ab51d9dd6 (diff)
implement basic user operations
Diffstat (limited to 'db/user.go')
-rw-r--r--db/user.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/db/user.go b/db/user.go
index 61e05ad..27e6f89 100644
--- a/db/user.go
+++ b/db/user.go
@@ -9,7 +9,7 @@ import (
func getNextUserId(db *sql.DB) (int, error) {
- row := db.QueryRow("select max(userid) from users;")
+ row := db.QueryRow("select coalesce(max(userid), 0) from users;")
if row.Err() != nil {
return -1, row.Err()
}
@@ -19,7 +19,7 @@ func getNextUserId(db *sql.DB) (int, error) {
if err != nil {
return -1, err
}
- return id, nil
+ return id+1, nil
}