postgres

package
v0.0.0-...-455cc0d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SessionTable string = "user_session"

Session table name.

View Source
const UserTable string = "user"

User table name.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresRepository

type PostgresRepository struct {
	User
	Session
}

Postgres repository structure.

func NewPostgresRepository

func NewPostgresRepository(cfg config.PostgresConfig) *PostgresRepository

Creating a new postgres repository.

type Session

type Session interface {
	Create(ctx context.Context, session domain.Session) error
	GetUserId(ctx context.Context, refreshToken, ip string) (ksuid.KSUID, error)
	Delete(ctx context.Context, refreshToken, ip string) error
}

User session repository interface.

type SessionRepository

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

User session repository structure.

func NewSessionRepository

func NewSessionRepository(psql postgres.Postgres) *SessionRepository

Creating a new user session repository.

func (*SessionRepository) Create

func (r *SessionRepository) Create(ctx context.Context, session domain.Session) error

Creating a new user session in postgres database.

func (*SessionRepository) Delete

func (r *SessionRepository) Delete(ctx context.Context, refreshToken, ip string) error

Deleting a user session in postgres database.

func (*SessionRepository) GetUserId

func (r *SessionRepository) GetUserId(ctx context.Context, refreshToken, ip string) (ksuid.KSUID, error)

Getting user id by refresh token in postgres database.

type User

type User interface {
	Create(ctx context.Context, user domain.User) error
	GetByID(ctx context.Context, id ksuid.KSUID) (domain.User, error)
	GetByUsername(ctx context.Context, username string) (domain.User, error)
	ForgotPassword(ctx context.Context, password, email string) error
	UpdateAvatar(ctx context.Context, avatarUrl string, id ksuid.KSUID) error
}

User repository interface.

type UserRepository

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

User repository structure.

func NewUserRepository

func NewUserRepository(psql postgres.Postgres) *UserRepository

Creating a new user repository.

func (*UserRepository) Create

func (r *UserRepository) Create(ctx context.Context, user domain.User) error

Creating a new user in postgres database.

func (*UserRepository) ForgotPassword

func (r *UserRepository) ForgotPassword(ctx context.Context, password, email string) error

Forgot password in postgres database.

func (*UserRepository) GetByID

func (r *UserRepository) GetByID(ctx context.Context, id ksuid.KSUID) (domain.User, error)

Get user by id in postgres database.

func (*UserRepository) GetByUsername

func (r *UserRepository) GetByUsername(ctx context.Context, username string) (domain.User, error)

Get user by username in postgres database.

func (*UserRepository) UpdateAvatar

func (r *UserRepository) UpdateAvatar(ctx context.Context, avatarUrl string, id ksuid.KSUID) error

Update user avatar in postgres database.

Jump to

Keyboard shortcuts

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