sqlstore

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidLinkError = errors.New("The passed link is not valid")
	ExistLinkError   = errors.New("The desired link already exists")
)

Functions

func SetupTestDB

func SetupTestDB(t *testing.T, tokenForAdmin string) (*sql.DB, func(...string))

func TestDB

func TestDB(t *testing.T, databasePath string) (*sql.DB, func(...string))

Types

type LinkRepository

type LinkRepository struct {
	ExpDuration time.Duration
	DelDuration time.Duration
	// contains filtered or unexported fields
}

func (*LinkRepository) Create

func (l *LinkRepository) Create(ctx context.Context, UID int, originLink string, preferredLink string) (*models.Link, error)

Заменить вызов двух функций на транзакцию

func (*LinkRepository) Delete

func (l *LinkRepository) Delete(ctx context.Context, originLink string) error
func (l *LinkRepository) GetByOriginLink(ctx context.Context, originLink string) (*models.Link, error)
func (l *LinkRepository) GetByShortLink(ctx context.Context, shortLink string) (*models.Link, error)

func (*LinkRepository) GetByUID

func (l *LinkRepository) GetByUID(ctx context.Context, uid int) ([]*models.Link, error)

func (*LinkRepository) ReActivate

func (l *LinkRepository) ReActivate(ctx context.Context, originLink string) error

func (*LinkRepository) ShortLinkExist

func (l *LinkRepository) ShortLinkExist(ctx context.Context, shortLink string) (bool, error)

type Store

type Store struct {
	QueryTimeout time.Duration
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, QueryTimeout time.Duration) *Store
func (s *Store) Link() store.LinkRepository

func (*Store) User

func (s *Store) User() store.UserRepository

type UserRepository

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

func (*UserRepository) CheckByToken

func (u *UserRepository) CheckByToken(ctx context.Context, token string) (bool, error)

func (*UserRepository) Create

func (u *UserRepository) Create(ctx context.Context) (*models.User, error)

func (*UserRepository) Delete

func (u *UserRepository) Delete(ctx context.Context, unique interface{}) error

func (*UserRepository) GetByRole

func (u *UserRepository) GetByRole(ctx context.Context, role string, limit int, offset int) ([]models.User, error)

func (*UserRepository) GetByToken

func (u *UserRepository) GetByToken(ctx context.Context, token string) (*models.User, error)

func (*UserRepository) GetByUID

func (u *UserRepository) GetByUID(ctx context.Context, uid int) (*models.User, error)

Jump to

Keyboard shortcuts

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