diff options
| author | Alexander Kavon <hawk@alexkavon.com> | 2023-11-29 19:16:50 -0500 |
|---|---|---|
| committer | Alexander Kavon <hawk@alexkavon.com> | 2023-11-29 19:19:12 -0500 |
| commit | f3515313f4d79dad5ad2ff8c72353e00e1c9cc70 (patch) | |
| tree | 01b0513f3fdb4cef0a4aaf67f4bc6c967856a4ab /src/user | |
| parent | 1c32e1497525bc6f609898f0f79bd6cc3e6d92fb (diff) | |
pass DbValues and convert to pgx.NamedArgs in db.go to save an import
Diffstat (limited to 'src/user')
| -rw-r--r-- | src/user/user.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/user/user.go b/src/user/user.go index e35c7c5..d9fca6b 100644 --- a/src/user/user.go +++ b/src/user/user.go @@ -6,7 +6,6 @@ import ( "fmt" "time" - "github.com/jackc/pgx/v5" "gitlab.com/alexkavon/newsstand/src/db" "golang.org/x/crypto/argon2" ) @@ -23,11 +22,17 @@ type User struct { Db *db.Database } +func NewUser(d *db.Database) *User { + return &User{ + Db: d, + } +} + func (u *User) Insert() error { err := u.Db.InsertTable( "users", []string{"username", "secret", "email"}, - pgx.NamedArgs{"username": u.Username, "secret": string(u.hash), "email": u.Email}, + db.DbValues{"username": u.Username, "secret": string(u.hash), "email": u.Email}, ) if err != nil { return err |
