persistence

package
v0.0.0-...-b248145 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateVoteParams

type CreateVoteParams struct {
	Pollid    uuid.UUID `db:"pollid" json:"pollid"`
	Optionkey string    `db:"optionkey" json:"optionkey"`
	Clientid  string    `db:"clientid" json:"clientid"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type GetNextPollRow

type GetNextPollRow struct {
	ID       uuid.UUID       `db:"id" json:"id"`
	Question string          `db:"question" json:"question"`
	Options  json.RawMessage `db:"options" json:"options"`
}

type GetPollRow

type GetPollRow struct {
	ID       uuid.UUID       `db:"id" json:"id"`
	Question string          `db:"question" json:"question"`
	Options  json.RawMessage `db:"options" json:"options"`
}

type GetPresentationAndPollParams

type GetPresentationAndPollParams struct {
	PresentationID uuid.UUID `db:"presentation_id" json:"presentation_id"`
	PollID         uuid.UUID `db:"poll_id" json:"poll_id"`
}

type GetPresentationAndPollRow

type GetPresentationAndPollRow struct {
	PresentationID   uuid.UUID     `db:"presentation_id" json:"presentation_id"`
	Currentpollindex sql.NullInt32 `db:"currentpollindex" json:"currentpollindex"`
	PollID           uuid.UUID     `db:"poll_id" json:"poll_id"`
	Question         string        `db:"question" json:"question"`
	Pollindex        int32         `db:"pollindex" json:"pollindex"`
}

type GetPreviousPollRow

type GetPreviousPollRow struct {
	ID       uuid.UUID       `db:"id" json:"id"`
	Question string          `db:"question" json:"question"`
	Options  json.RawMessage `db:"options" json:"options"`
}

type GetVotesParams

type GetVotesParams struct {
	PresentationID uuid.UUID `db:"presentation_id" json:"presentation_id"`
	PollID         uuid.UUID `db:"poll_id" json:"poll_id"`
}

type GetVotesRow

type GetVotesRow struct {
	Key      string `db:"key" json:"key"`
	ClientID string `db:"client_id" json:"client_id"`
}

type ListPollsRow

type ListPollsRow struct {
	ID       uuid.UUID       `db:"id" json:"id"`
	Question string          `db:"question" json:"question"`
	Options  json.RawMessage `db:"options" json:"options"`
}

type Option

type Option struct {
	ID          uuid.UUID `db:"id" json:"id"`
	Pollid      uuid.UUID `db:"pollid" json:"pollid"`
	Optionkey   string    `db:"optionkey" json:"optionkey"`
	Optionvalue string    `db:"optionvalue" json:"optionvalue"`
}

type Poll

type Poll struct {
	ID             uuid.UUID    `db:"id" json:"id"`
	Presentationid uuid.UUID    `db:"presentationid" json:"presentationid"`
	Question       string       `db:"question" json:"question"`
	Pollindex      int32        `db:"pollindex" json:"pollindex"`
	Createdat      sql.NullTime `db:"createdat" json:"createdat"`
}

type Presentation

type Presentation struct {
	ID               uuid.UUID     `db:"id" json:"id"`
	Currentpollindex sql.NullInt32 `db:"currentpollindex" json:"currentpollindex"`
}

type Querier

type Querier interface {
	CreatePresentationAndPolls(ctx context.Context, polls json.RawMessage) (uuid.UUID, error)
	CreateVote(ctx context.Context, arg CreateVoteParams) error
	GetNextPoll(ctx context.Context, id uuid.UUID) (GetNextPollRow, error)
	GetPoll(ctx context.Context, presentationid uuid.UUID) (GetPollRow, error)
	GetPresentation(ctx context.Context, id uuid.UUID) (Presentation, error)
	GetPresentationAndPoll(ctx context.Context, arg GetPresentationAndPollParams) (GetPresentationAndPollRow, error)
	GetPreviousPoll(ctx context.Context, id uuid.UUID) (GetPreviousPollRow, error)
	GetVotes(ctx context.Context, arg GetVotesParams) ([]GetVotesRow, error)
	ListPolls(ctx context.Context, presentationid uuid.UUID) ([]ListPollsRow, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreatePresentationAndPolls

func (q *Queries) CreatePresentationAndPolls(ctx context.Context, polls json.RawMessage) (uuid.UUID, error)

func (*Queries) CreateVote

func (q *Queries) CreateVote(ctx context.Context, arg CreateVoteParams) error

func (*Queries) GetNextPoll

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

func (*Queries) GetPoll

func (q *Queries) GetPoll(ctx context.Context, presentationid uuid.UUID) (GetPollRow, error)

func (*Queries) GetPresentation

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

func (*Queries) GetPresentationAndPoll

func (q *Queries) GetPresentationAndPoll(ctx context.Context, arg GetPresentationAndPollParams) (GetPresentationAndPollRow, error)

func (*Queries) GetPreviousPoll

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

func (*Queries) GetVotes

func (q *Queries) GetVotes(ctx context.Context, arg GetVotesParams) ([]GetVotesRow, error)

func (*Queries) ListPolls

func (q *Queries) ListPolls(ctx context.Context, presentationid uuid.UUID) ([]ListPollsRow, error)

func (*Queries) WithTx

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

type SQLStore

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

SQLStore provides all functions to execute SQL queries and transactions

func (*SQLStore) GetCurrentPoll

func (store *SQLStore) GetCurrentPoll(ctx context.Context, id uuid.UUID) (model.CurrentPoll, error)

func (*SQLStore) UpdateCurrentPollToForwardTx

func (store *SQLStore) UpdateCurrentPollToForwardTx(ctx context.Context, id uuid.UUID) (model.CurrentPoll, error)

func (*SQLStore) UpdateCurrentPollToPreviousTx

func (store *SQLStore) UpdateCurrentPollToPreviousTx(ctx context.Context, id uuid.UUID) (model.CurrentPoll, error)

func (*SQLStore) VoteCurrentPollTx

func (store *SQLStore) VoteCurrentPollTx(ctx context.Context, arg VoteParams) error

type Store

type Store interface {
	Querier
	GetCurrentPoll(context.Context, uuid.UUID) (model.CurrentPoll, error)
	UpdateCurrentPollToForwardTx(ctx context.Context, id uuid.UUID) (model.CurrentPoll, error)
	UpdateCurrentPollToPreviousTx(ctx context.Context, id uuid.UUID) (model.CurrentPoll, error)
	VoteCurrentPollTx(context.Context, VoteParams) error
}

Store defines all functions to execute db queries and transactions

func NewStore

func NewStore(db *sql.DB) Store

NewStore creates a new store

type Vote

type Vote struct {
	ID        uuid.UUID `db:"id" json:"id"`
	Pollid    uuid.UUID `db:"pollid" json:"pollid"`
	Optionkey string    `db:"optionkey" json:"optionkey"`
	Clientid  string    `db:"clientid" json:"clientid"`
}

type VoteParams

type VoteParams struct {
	PresentationID uuid.UUID
	Pollid         uuid.UUID `db:"pollid"`
	Optionkey      string    `db:"optionkey"`
	Clientid       string    `db:"clientid"`
}

Jump to

Keyboard shortcuts

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