postgres

package
v0.0.0-...-708a4bd Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUserRepo

func NewUserRepo(s *Storage) entities.UserRepo

Types

type CreateUserParams

type CreateUserParams struct {
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Password  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
}

type CreateUserRow

type CreateUserRow struct {
	ID        uuid.UUID
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
	CreatedAt pgtype.Timestamp
}

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 DatabaseError

type DatabaseError struct {
	Query string
	Err   error
}

func (*DatabaseError) Error

func (e *DatabaseError) Error() string

func (*DatabaseError) Unwrap

func (e *DatabaseError) Unwrap() error

type GetUserByEmailRow

type GetUserByEmailRow struct {
	ID        uuid.UUID
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
	CreatedAt pgtype.Timestamp
	UpdatedAt pgtype.Timestamp
}

type GetUserByNicknameRow

type GetUserByNicknameRow struct {
	ID        uuid.UUID
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
	CreatedAt pgtype.Timestamp
	UpdatedAt pgtype.Timestamp
}

type InternalServerError

type InternalServerError struct {
	Err error
}

func (*InternalServerError) Error

func (e *InternalServerError) Error() string

func (*InternalServerError) Unwrap

func (e *InternalServerError) Unwrap() error

type ListUsersParams

type ListUsersParams struct {
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
	CreatedAt pgtype.Timestamptz
	UpdatedAt pgtype.Timestamptz
	Limit     int32
	Offset    int32
}

type ListUsersRow

type ListUsersRow struct {
	ID        uuid.UUID
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
	CreatedAt pgtype.Timestamp
	UpdatedAt pgtype.Timestamp
}

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) (CreateUserRow, error)

func (*Queries) DeleteUser

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

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email pgtype.Text) (GetUserByEmailRow, error)

func (*Queries) GetUserByNickname

func (q *Queries) GetUserByNickname(ctx context.Context, nickname pgtype.Text) (GetUserByNicknameRow, error)

func (*Queries) ListUsers

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

func (*Queries) UpdateUser

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

func (*Queries) WithTx

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

type Storage

type Storage struct {
	Queries *Queries
	DB      *pgxpool.Pool
}

func NewStorage

func NewStorage(cfg *config.AppConfig) (*Storage, error)

NewStorage initializes the database connection and repositories.

type UpdateUserParams

type UpdateUserParams struct {
	ID        uuid.UUID
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
}

type Users

type Users struct {
	ID        uuid.UUID
	FirstName pgtype.Text
	LastName  pgtype.Text
	Nickname  pgtype.Text
	Password  pgtype.Text
	Email     pgtype.Text
	Country   pgtype.Text
	CreatedAt pgtype.Timestamp
	UpdatedAt pgtype.Timestamp
}

Jump to

Keyboard shortcuts

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