store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnonymousUser = &User{}

Functions

func Migrate

func Migrate(db *sql.DB, dir string) error

func MigrateFS

func MigrateFS(db *sql.DB, migrationFS fs.FS, dir string) error

func Open

func Open() (*sql.DB, error)

Types

type PostgresTokenStore

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

func NewPostgresTokenStore

func NewPostgresTokenStore(db *sql.DB) *PostgresTokenStore

func (*PostgresTokenStore) CreateNewToken

func (t *PostgresTokenStore) CreateNewToken(userID int, ttl time.Duration, scope string) (*tokens.Token, error)

func (*PostgresTokenStore) DeleteAllTokensForUser

func (t *PostgresTokenStore) DeleteAllTokensForUser(userID int, scope string) error

func (*PostgresTokenStore) Insert

func (t *PostgresTokenStore) Insert(token *tokens.Token) error

type PostgresUserStore

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

func NewPostgresUserStore

func NewPostgresUserStore(db *sql.DB) *PostgresUserStore

func (*PostgresUserStore) CreateUser

func (s *PostgresUserStore) CreateUser(u *User) error

func (*PostgresUserStore) GetUserByUsername

func (s *PostgresUserStore) GetUserByUsername(uname string) (*User, error)

func (*PostgresUserStore) GetUserToken

func (s *PostgresUserStore) GetUserToken(scope, plainTextPassword string) (*User, error)

func (*PostgresUserStore) UpdateUser

func (s *PostgresUserStore) UpdateUser(u *User) error

type PostgresWorkoutStore

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

func NewPostgresWorkoutStore

func NewPostgresWorkoutStore(db *sql.DB) *PostgresWorkoutStore

func (*PostgresWorkoutStore) CreateWorkout

func (pg *PostgresWorkoutStore) CreateWorkout(workout *Workout) (*Workout, error)

func (*PostgresWorkoutStore) DeleteWorkout

func (pg *PostgresWorkoutStore) DeleteWorkout(id int64) error

func (*PostgresWorkoutStore) GetWorkoutByID

func (pg *PostgresWorkoutStore) GetWorkoutByID(id int64) (*Workout, error)

func (*PostgresWorkoutStore) GetWorkoutOwner

func (pg *PostgresWorkoutStore) GetWorkoutOwner(workoutID int64) (int, error)

func (*PostgresWorkoutStore) UpdateWorkout

func (pg *PostgresWorkoutStore) UpdateWorkout(workout *Workout) error

type TokenStore

type TokenStore interface {
	Insert(token *tokens.Token) error
	CreateNewToken(userID int, ttl time.Duration, scope string) (*tokens.Token, error)
	DeleteAllTokensForUser(userID int, scope string) error
}

type User

type User struct {
	ID           int       `json:"id"`
	Username     string    `json:"username"`
	Email        string    `json:"email"`
	PasswordHash password  `json:"_"`
	Bio          string    `json:"bio"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
}

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

type UserStore

type UserStore interface {
	CreateUser(*User) error
	GetUserByUsername(username string) (*User, error)
	UpdateUser(*User) error
	GetUserToken(scope, tokenPlainText string) (*User, error)
}

type Workout

type Workout struct {
	ID              int            `json:"id"`
	UserID          int            `json:"user_id"`
	Title           string         `json:"title"`
	Description     string         `json:"description"`
	DurationMinutes int            `json:"duration_minutes"`
	CaloriesBurned  int            `json:"calories_burned"`
	Entries         []WorkoutEntry `json:"entries"`
}

type WorkoutEntry

type WorkoutEntry struct {
	ID              int      `json:"id"`
	ExerciseName    string   `json:"exercise_name"`
	Sets            int      `json:"sets"`
	Reps            *int     `json:"reps"`
	DurationSeconds *int     `json:"duration_seconds"`
	Weight          *float64 `json:"weight"`
	Notes           string   `json:"notes"`
	OrderIndex      int      `json:"order_index"`
}

type WorkoutStore

type WorkoutStore interface {
	CreateWorkout(*Workout) (*Workout, error)
	GetWorkoutByID(id int64) (*Workout, error)
	UpdateWorkout(*Workout) error
	DeleteWorkout(id int64) error
	GetWorkoutOwner(workoutID int64) (int, error)
}

Jump to

Keyboard shortcuts

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