From f3515313f4d79dad5ad2ff8c72353e00e1c9cc70 Mon Sep 17 00:00:00 2001 From: Alexander Kavon Date: Wed, 29 Nov 2023 19:16:50 -0500 Subject: pass DbValues and convert to pgx.NamedArgs in db.go to save an import --- src/user/user.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/user') 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 -- cgit v1.2.3