postgres

package
v0.0.0-...-5e83000 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: BSD-2-Clause-Patent Imports: 10 Imported by: 0

Documentation

Overview

Package postgres contains repository implementation for postgres database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, dsn string, log pgx.Logger, logLevel string) (*pgxpool.Pool, error)

Connect connects to postgres database.

Types

type User

type User struct {
	ID              string
	Email           string
	Password        pgtype.Bytea
	Activated       pgtype.Timestamptz
	Created         pgtype.Timestamptz
	Updated         pgtype.Timestamptz
	ActivationToken pgtype.UUID
	RecoveryToken   pgtype.UUID
	Active          bool
}

User entity.

func (*User) DomainUser

func (u *User) DomainUser() (*domain.User, error)

DomainUser converts user entity to domain user.

type UsersRepository

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

UsersRepository implements repository.Users interface using PostgreSQL database.

func NewUserRepository

func NewUserRepository(conn *pgxpool.Pool) *UsersRepository

NewUserRepository creates new users repository using PostgreSQL database.

func (*UsersRepository) Activate

func (repo *UsersRepository) Activate(ctx context.Context, token string) (*domain.User, error)

Activate activates user account in PostgreSQL database.

func (*UsersRepository) Create

func (repo *UsersRepository) Create(ctx context.Context, email string, password []byte) (*domain.User, error)

Create creates new user in PostgreSQL database.

func (*UsersRepository) FetchRecoveryToken

func (repo *UsersRepository) FetchRecoveryToken(ctx context.Context, email string) (*domain.User, error)

FetchRecoveryToken sets user's password reset token in PostgreSQL repository.

func (*UsersRepository) FindAll

func (repo *UsersRepository) FindAll(ctx context.Context) ([]domain.User, error)

FindAll fetches alls users from PostgreSQL.

func (*UsersRepository) FindOne

func (repo *UsersRepository) FindOne(ctx context.Context, id string) (*domain.User, error)

FindOne fetches user from PostgreSQL database using ID.

func (*UsersRepository) FindOneByEmail

func (repo *UsersRepository) FindOneByEmail(ctx context.Context, email string) (*domain.User, error)

FindOneByEmail fetches user from PostgreSQL database using email address.

func (*UsersRepository) ResetPassword

func (repo *UsersRepository) ResetPassword(ctx context.Context, recoveryToken string,
	password []byte,
) (*domain.User, error)

ResetPassword sets new user's password in PostgreSQL database.

Jump to

Keyboard shortcuts

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