database

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateUserParams

type CreateUserParams struct {
	Email       string      `json:"email"`
	Username    string      `json:"username"`
	PhoneNumber pgtype.Text `json:"phone_number"`
	Password    string      `json:"password"`
	Role        string      `json:"role"`
	IsVerified  pgtype.Bool `json:"is_verified"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetUserByResetTokenRow

type GetUserByResetTokenRow struct {
	ID          int32              `json:"id"`
	Email       string             `json:"email"`
	Username    string             `json:"username"`
	PhoneNumber pgtype.Text        `json:"phone_number"`
	Password    string             `json:"password"`
	Role        string             `json:"role"`
	IsVerified  pgtype.Bool        `json:"is_verified"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type Querier

type Querier interface {
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteUser(ctx context.Context, id int32) error
	GetUser(ctx context.Context, id int32) (User, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserByResetToken(ctx context.Context, resetToken pgtype.Text) (GetUserByResetTokenRow, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
	ResetPassword(ctx context.Context, arg ResetPasswordParams) (User, error)
	UpdateResetToken(ctx context.Context, arg UpdateResetTokenParams) error
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
	VerifyUser(ctx context.Context, email string) error
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int32) error

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int32) (User, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) GetUserByResetToken

func (q *Queries) GetUserByResetToken(ctx context.Context, resetToken pgtype.Text) (GetUserByResetTokenRow, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) ResetPassword

func (q *Queries) ResetPassword(ctx context.Context, arg ResetPasswordParams) (User, error)

func (*Queries) UpdateResetToken

func (q *Queries) UpdateResetToken(ctx context.Context, arg UpdateResetTokenParams) error

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) VerifyUser

func (q *Queries) VerifyUser(ctx context.Context, email string) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ResetPasswordParams

type ResetPasswordParams struct {
	Password   string      `json:"password"`
	ResetToken pgtype.Text `json:"reset_token"`
	Email      string      `json:"email"`
}

type UpdateResetTokenParams

type UpdateResetTokenParams struct {
	ResetToken       pgtype.Text        `json:"reset_token"`
	ResetTokenExpiry pgtype.Timestamptz `json:"reset_token_expiry"`
	Email            string             `json:"email"`
}

type UpdateUserParams

type UpdateUserParams struct {
	ID       int32  `json:"id"`
	Username string `json:"username"`
}

type User

type User struct {
	ID          int32       `json:"id"`
	Email       string      `json:"email"`
	Username    string      `json:"username"`
	PhoneNumber pgtype.Text `json:"phone_number"`
	// hashed password
	Password string `json:"password"`
	// role-based access: admin, seller, or buyer
	Role             string             `json:"role"`
	IsVerified       pgtype.Bool        `json:"is_verified"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	ResetToken       pgtype.Text        `json:"reset_token"`
	ResetTokenExpiry pgtype.Timestamptz `json:"reset_token_expiry"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL