models

package
v0.0.0-...-5d0d596 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateEmail     = errors.New("models: duplicate email")
	ErrInvalidCredentials = errors.New("models: invalid credentials")
	ErrDuplicateUsername  = errors.New("models: duplicate username")
)

Functions

This section is empty.

Types

type AllParts

type AllParts struct {
	Keyboards       []Keyboard
	Switches        []Keyswitch
	PlateMaterials  []PlateMaterial
	KeycapMaterials []KeycapMaterial
}

type Keyboard

type Keyboard struct {
	ID   uuid.UUID
	Name string
}

type KeycapMaterial

type KeycapMaterial struct {
	ID   uuid.UUID
	Name string
}

type Keyswitch

type Keyswitch struct {
	ID                uuid.UUID
	Name              string
	KeyswitchTypeID   uuid.UUID
	KeyswitchTypeName string
}

type PartsModel

type PartsModel struct {
	DB *pgxpool.Pool
}

func (*PartsModel) GetAll

func (m *PartsModel) GetAll() (AllParts, error)

func (*PartsModel) GetDaily

func (m *PartsModel) GetDaily(correctKeyboard, correctSwitch, correctPlate uuid.UUID) (AllParts, error)

func (*PartsModel) GetKeyboardOpts

func (m *PartsModel) GetKeyboardOpts(correctKeyboard uuid.UUID) ([]Keyboard, error)

func (*PartsModel) GetKeyboards

func (m *PartsModel) GetKeyboards() ([]Keyboard, error)

func (*PartsModel) GetKeycapMaterials

func (m *PartsModel) GetKeycapMaterials() ([]KeycapMaterial, error)

func (*PartsModel) GetPlateMaterials

func (m *PartsModel) GetPlateMaterials() ([]PlateMaterial, error)

func (*PartsModel) GetPlateOpts

func (m *PartsModel) GetPlateOpts(correctPlate uuid.UUID) ([]PlateMaterial, error)

func (*PartsModel) GetSwitchOpts

func (m *PartsModel) GetSwitchOpts(correctSwitch uuid.UUID) ([]Keyswitch, error)

func (*PartsModel) GetSwitches

func (m *PartsModel) GetSwitches() ([]Keyswitch, error)

type PlateMaterial

type PlateMaterial struct {
	ID   uuid.UUID
	Name string
}

type ProfileInfo

type ProfileInfo struct {
	ID          uuid.UUID
	Email       string
	LastUpdated time.Time
	Name        string
	Username    string
}

type SoundTest

type SoundTest struct {
	ID               uuid.UUID
	URL              string
	Uploaded         time.Time
	LastUpdated      time.Time
	KeyboardID       uuid.UUID
	PlateMaterialID  uuid.UUID
	KeycapMaterialID uuid.UUID
	KeyswitchID      uuid.UUID
	CreatedBy        uuid.UUID
	FeaturedOn       time.Time
}

type SoundTestModel

type SoundTestModel struct {
	DB *pgxpool.Pool
}

func (*SoundTestModel) AddPlay

func (m *SoundTestModel) AddPlay(soundtest uuid.UUID, userID, keyboard, plateMaterial, keycapMaterial, keyswitch string) error

func (*SoundTestModel) GetDaily

func (m *SoundTestModel) GetDaily() (SoundTest, error)

func (*SoundTestModel) GetLatest

func (m *SoundTestModel) GetLatest(page int, perPage int, userID string) ([]SoundTestVote, error)

func (*SoundTestModel) GetPlay

func (m *SoundTestModel) GetPlay(userID string) (SoundTestPlay, error)

func (*SoundTestModel) Insert

func (m *SoundTestModel) Insert(fileURL, keyboard, plateMaterial, keycapMaterial, keyswitch, userID string) error

type SoundTestPlay

type SoundTestPlay struct {
	SoundTestID           uuid.UUID
	URL                   string
	Submitted             time.Time
	CreatedBy             string
	Keyboard              string
	CorrectKeyboard       string
	PlateMaterial         string
	CorrectPlateMaterial  string
	KeycapMaterial        string
	CorrectKeycapMaterial string
	Keyswitch             string
	CorrectKeyswitch      string
}

type SoundTestVote

type SoundTestVote struct {
	ID          uuid.UUID
	URL         string
	Uploaded    time.Time
	LastUpdated time.Time
	CreatedBy   string
	UserVote    int
	TotalVotes  int
	TotalTests  int
}

type User

type User struct {
	ID             uuid.UUID
	Email          string
	HashedPassword []byte
	Created        time.Time
	LastUpdated    time.Time
	Name           string
	Username       string
}

type UserModel

type UserModel struct {
	DB *pgxpool.Pool
}

func (*UserModel) Authenticate

func (m *UserModel) Authenticate(email, password string) (uuid.UUID, error)

func (*UserModel) Exists

func (m *UserModel) Exists(id string) (bool, error)

func (*UserModel) GetProfileInfo

func (m *UserModel) GetProfileInfo(userID string) (ProfileInfo, error)

func (*UserModel) Insert

func (m *UserModel) Insert(email, password string) error

func (*UserModel) UpdateProfile

func (m *UserModel) UpdateProfile(userID, email, name, username string) error

type Vote

type Vote struct {
	ID        uuid.UUID
	VoteType  int
	Timestamp time.Time
	CreatedBy uuid.UUID
}

type VoteModel

type VoteModel struct {
	DB *pgxpool.Pool
}

func (*VoteModel) Upsert

func (m *VoteModel) Upsert(soundtestID string, voteType int, userID string) error

Jump to

Keyboard shortcuts

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