store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	Close()
}

type QuerierFactory

type QuerierFactory func(tx db.DBTX) db.Querier

type Store

type Store interface {
	StartPrediction(ctx context.Context, userID uuid.UUID, scanURL string) (*models.Prediction, error)
	CompletePrediction(ctx context.Context, id uuid.UUID, result models.PredictionResult, err error) error
	GetPrediction(ctx context.Context, id uuid.UUID) (*models.Prediction, error)
	GetPredictionsByUserID(ctx context.Context, userID uuid.UUID, offset, limit int) ([]*models.Prediction, error)

	CreateUser(ctx context.Context, user *models.User) error
	GetUser(ctx context.Context, id uuid.UUID, withStats bool) (*models.User, error)
	GetUserByLogin(ctx context.Context, login string) (*models.User, error)
	UpdateUserPass(ctx context.Context, id uuid.UUID, newHashedPass string) error
	UpdateAvatar(ctx context.Context, user *models.User) error
	DeleteUser(ctx context.Context, id uuid.UUID) error

	InsertRefreshToken(ctx context.Context, refreshToken *models.RefreshToken) error
	GetRefreshTokenByHash(ctx context.Context, tokenHash string) (*models.RefreshToken, error)
	RevokeRefreshToken(ctx context.Context, tokenHash string) error
	RevokeAllUserTokens(ctx context.Context, userID uuid.UUID) error

	UpdateStats(ctx context.Context, stat *models.Stat) error

	InsertLoginHistory(ctx context.Context, loginHistory *models.LoginHistory) error
	GetLoginHistory(ctx context.Context, userID uuid.UUID) ([]models.LoginHistory, error)

	Close()
	Conn() *pgxpool.Pool
	WithTx(tx pgx.Tx) Store
	BeginTx(ctx context.Context) (pgx.Tx, error)
	ExecTx(ctx context.Context, fn func(Store) error) error
}

func CreatePgStore

func CreatePgStore(conf config.Config) (Store, error)

func NewPgStore

func NewPgStore(q db.Querier, qf QuerierFactory, pool Connection) Store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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