db

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletePredictionParams

type CompletePredictionParams struct {
	Status string    `json:"status"`
	Result []byte    `json:"result"`
	Error  *string   `json:"error"`
	ID     uuid.UUID `json:"id"`
}

type CreateLoginHistoryParams

type CreateLoginHistoryParams struct {
	UserID        uuid.UUID   `json:"user_id"`
	Success       bool        `json:"success"`
	FailureReason *string     `json:"failure_reason"`
	IpAddress     *netip.Addr `json:"ip_address"`
	UserAgent     *string     `json:"user_agent"`
	Location      *string     `json:"location"`
}

type CreateNewPredictionParams

type CreateNewPredictionParams struct {
	UserID    uuid.UUID `json:"user_id"`
	TrashScan string    `json:"trash_scan"`
	Status    string    `json:"status"`
}

type CreateRefreshTokenParams

type CreateRefreshTokenParams struct {
	UserID    uuid.UUID `json:"user_id"`
	TokenHash string    `json:"token_hash"`
	ExpiresAt time.Time `json:"expires_at"`
}

type CreateUserParams

type CreateUserParams struct {
	Name           string `json:"name"`
	Login          string `json:"login"`
	HashedPassword string `json:"hashed_password"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetLoginHistoryByUserParams

type GetLoginHistoryByUserParams struct {
	UserID uuid.UUID `json:"user_id"`
	Limit  int32     `json:"limit"`
	Offset int32     `json:"offset"`
}

type GetPredictionsByUserIDParams

type GetPredictionsByUserIDParams struct {
	UserID uuid.UUID `json:"user_id"`
	Limit  int32     `json:"limit"`
	Offset int32     `json:"offset"`
}

type LoginHistory

type LoginHistory struct {
	ID            uuid.UUID   `json:"id"`
	UserID        uuid.UUID   `json:"user_id"`
	Success       bool        `json:"success"`
	FailureReason *string     `json:"failure_reason"`
	IpAddress     *netip.Addr `json:"ip_address"`
	UserAgent     *string     `json:"user_agent"`
	Location      *string     `json:"location"`
	CreatedAt     time.Time   `json:"created_at"`
}

type Prediction

type Prediction struct {
	ID        uuid.UUID `json:"id"`
	UserID    uuid.UUID `json:"user_id"`
	TrashScan string    `json:"trash_scan"`
	Status    string    `json:"status"`
	Result    []byte    `json:"result"`
	Error     *string   `json:"error"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Querier

type Querier interface {
	CompletePrediction(ctx context.Context, arg CompletePredictionParams) error
	CreateLoginHistory(ctx context.Context, arg CreateLoginHistoryParams) (uuid.UUID, error)
	CreateNewPrediction(ctx context.Context, arg CreateNewPredictionParams) (Prediction, error)
	CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (uuid.UUID, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (uuid.UUID, error)
	DeleteUser(ctx context.Context, id uuid.UUID) error
	GetActiveTokensByUser(ctx context.Context, userID uuid.UUID) ([]RefreshToken, error)
	GetLoginHistoryByUser(ctx context.Context, arg GetLoginHistoryByUserParams) ([]LoginHistory, error)
	GetPrediction(ctx context.Context, id uuid.UUID) (Prediction, error)
	GetPredictionsByUserID(ctx context.Context, arg GetPredictionsByUserIDParams) ([]Prediction, error)
	GetRefreshTokenByHash(ctx context.Context, tokenHash string) (RefreshToken, error)
	GetStatsByUserID(ctx context.Context, userID uuid.UUID) (Stat, error)
	GetUserByID(ctx context.Context, id uuid.UUID) (User, error)
	GetUserByLogin(ctx context.Context, login string) (User, error)
	RevokeAllUserTokens(ctx context.Context, userID uuid.UUID) error
	RevokeRefreshToken(ctx context.Context, tokenHash string) error
	UpdateStats(ctx context.Context, arg UpdateStatsParams) error
	UpdateUser(ctx context.Context, arg UpdateUserParams) error
	UpdateUserAvatar(ctx context.Context, arg UpdateUserAvatarParams) error
	UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CompletePrediction

func (q *Queries) CompletePrediction(ctx context.Context, arg CompletePredictionParams) error

func (*Queries) CreateLoginHistory

func (q *Queries) CreateLoginHistory(ctx context.Context, arg CreateLoginHistoryParams) (uuid.UUID, error)

func (*Queries) CreateNewPrediction

func (q *Queries) CreateNewPrediction(ctx context.Context, arg CreateNewPredictionParams) (Prediction, error)

func (*Queries) CreateRefreshToken

func (q *Queries) CreateRefreshToken(ctx context.Context, arg CreateRefreshTokenParams) (uuid.UUID, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (uuid.UUID, error)

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id uuid.UUID) error

func (*Queries) GetActiveTokensByUser

func (q *Queries) GetActiveTokensByUser(ctx context.Context, userID uuid.UUID) ([]RefreshToken, error)

func (*Queries) GetLoginHistoryByUser

func (q *Queries) GetLoginHistoryByUser(ctx context.Context, arg GetLoginHistoryByUserParams) ([]LoginHistory, error)

func (*Queries) GetPrediction

func (q *Queries) GetPrediction(ctx context.Context, id uuid.UUID) (Prediction, error)

func (*Queries) GetPredictionsByUserID

func (q *Queries) GetPredictionsByUserID(ctx context.Context, arg GetPredictionsByUserIDParams) ([]Prediction, error)

func (*Queries) GetRefreshTokenByHash

func (q *Queries) GetRefreshTokenByHash(ctx context.Context, tokenHash string) (RefreshToken, error)

func (*Queries) GetStatsByUserID

func (q *Queries) GetStatsByUserID(ctx context.Context, userID uuid.UUID) (Stat, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id uuid.UUID) (User, error)

func (*Queries) GetUserByLogin

func (q *Queries) GetUserByLogin(ctx context.Context, login string) (User, error)

func (*Queries) RevokeAllUserTokens

func (q *Queries) RevokeAllUserTokens(ctx context.Context, userID uuid.UUID) error

func (*Queries) RevokeRefreshToken

func (q *Queries) RevokeRefreshToken(ctx context.Context, tokenHash string) error

func (*Queries) UpdateStats

func (q *Queries) UpdateStats(ctx context.Context, arg UpdateStatsParams) error

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error

func (*Queries) UpdateUserAvatar

func (q *Queries) UpdateUserAvatar(ctx context.Context, arg UpdateUserAvatarParams) error

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RefreshToken

type RefreshToken struct {
	ID        uuid.UUID          `json:"id"`
	UserID    uuid.UUID          `json:"user_id"`
	TokenHash string             `json:"token_hash"`
	ExpiresAt time.Time          `json:"expires_at"`
	Revoked   bool               `json:"revoked"`
	RevokedAt pgtype.Timestamptz `json:"revoked_at"`
	CreatedAt time.Time          `json:"created_at"`
	UpdatedAt time.Time          `json:"updated_at"`
}

type Stat

type Stat struct {
	ID            uuid.UUID          `json:"id"`
	UserID        uuid.UUID          `json:"user_id"`
	Status        string             `json:"status"`
	Rating        int32              `json:"rating"`
	FilesScanned  int32              `json:"files_scanned"`
	TotalWeight   float64            `json:"total_weight"`
	Achievements  []byte             `json:"achievements"`
	TrashByTypes  []byte             `json:"trash_by_types"`
	LastScannedAt pgtype.Timestamptz `json:"last_scanned_at"`
	CreatedAt     time.Time          `json:"created_at"`
	UpdatedAt     time.Time          `json:"updated_at"`
}

type UpdateStatsParams

type UpdateStatsParams struct {
	Status        string             `json:"status"`
	Rating        int32              `json:"rating"`
	FilesScanned  int32              `json:"files_scanned"`
	TotalWeight   float64            `json:"total_weight"`
	Achievements  []byte             `json:"achievements"`
	TrashByTypes  []byte             `json:"trash_by_types"`
	LastScannedAt pgtype.Timestamptz `json:"last_scanned_at"`
	ID            uuid.UUID          `json:"id"`
}

type UpdateUserAvatarParams

type UpdateUserAvatarParams struct {
	Avatar *string   `json:"avatar"`
	ID     uuid.UUID `json:"id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	Name string    `json:"name"`
	ID   uuid.UUID `json:"id"`
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	HashedPassword string    `json:"hashed_password"`
	ID             uuid.UUID `json:"id"`
}

type User

type User struct {
	ID             uuid.UUID `json:"id"`
	Login          string    `json:"login"`
	Name           string    `json:"name"`
	HashedPassword string    `json:"hashed_password"`
	Avatar         *string   `json:"avatar"`
	Deleted        bool      `json:"deleted"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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