repo

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package repo provides interfaces and structures to interact with database.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows = errors.New("no rows in result set")
)

Functions

func NewRolePostgres

func NewRolePostgres(db *db.Postgres) *rolePostgres

NewRolePostgres creates a new rolePostgres. It returns pointer to a rolePostgres instance.

func NewTokenPostgres

func NewTokenPostgres(db *db.Postgres) *tokenPostgres

NewTokenPostgres creates a new tokenPostgres. It returns pointer to a tokenPostgres instance.

func NewUserPostgres

func NewUserPostgres(db *db.Postgres) *userPostgres

NewUserPostgres creates a new userPostgres. It returns pointer to an userPostgres instance.

Types

type Role

type Role interface {
	// Create creates a new role.
	// It returns pointer to an entity.Role instance.
	Create(ctx context.Context, data entity.Role) (*entity.Role, error)

	// GetByID gets a role by ID.
	// It returns pointer to an entity.Role instance.
	GetByID(ctx context.Context, id uuid.UUID) (*entity.Role, error)

	// GetByUser gets roles by user ID.
	// It returns slice of entity.Role instances.
	GetByUser(ctx context.Context, userID uuid.UUID) ([]entity.Role, error)

	// DeleteByID deletes a role by ID.
	DeleteByID(ctx context.Context, id uuid.UUID) error

	// DeleteByUser deletes user-related roles by user ID.
	DeleteByUser(ctx context.Context, userID uuid.UUID) error
}

Role is interface implemented by types that can interact with role entity.

type Token

type Token interface {
	// Create creates a new refresh token.
	// It returns pointer to an entity.RefreshToken instance.
	Create(ctx context.Context, data entity.RefreshToken) (*entity.RefreshToken, error)

	// GetByID gets a refresh token by ID.
	// It returns pointer to an entity.RefreshToken instance.
	GetByID(ctx context.Context, id uuid.UUID) (*entity.RefreshToken, error)

	// GetByUser gets refresh tokens by user ID.
	// It returns slice of entity.RefreshToken instances.
	GetByUser(ctx context.Context, userID uuid.UUID) ([]entity.RefreshToken, error)

	// DeleteByID deletes a refresh token by ID.
	DeleteByID(ctx context.Context, id uuid.UUID) error

	// DeleteByUser deletes user-related refresh tokens by user ID.
	DeleteByUser(ctx context.Context, userID uuid.UUID) error
}

Token is interface implemented by types that can interact with token entity.

type User

type User interface {
	// Create creates a new user.
	// It returns pointer to an entity.User instance.
	Create(ctx context.Context, data entity.User) (*entity.User, error)

	// GetByID gets a user by ID.
	// It returns pointer to an entity.User instance.
	GetByID(ctx context.Context, id uuid.UUID) (*entity.User, error)

	// GetByName gets a user by unique name.
	// It returns pointer to an entity.User instance.
	GetByName(ctx context.Context, name string) (*entity.User, error)

	// UpdatePassword updates user's password by user ID.
	UpdatePassword(ctx context.Context, id uuid.UUID, password []byte) error

	// DeleteByID deletes a user by ID.
	DeleteByID(ctx context.Context, id uuid.UUID) error
}

User is interface implemented by types that can interact with user entity.

Jump to

Keyboard shortcuts

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