store

package
v0.0.0-...-ea178e4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInvalidEmail is returned when the email is not a valid address or is empty.
	ErrInvalidEmail = errors.Error("invalid_email: email is invalid")
	// ErrQuestAlreadySentToEmail is returned when the email address is already used via another user.
	ErrQuestAlreadySentToEmail = errors.Error("Quest is already sent to this email")
	// ErrEmptyNickname is returned when the nickname is empty.
	ErrEmptyNickname = errors.Error("empty_nickname: nickname is empty")
	// ErrNicknameAlreadyUsed is returned when the nickname is already used via another user.
	ErrNicknameAlreadyUsed = errors.Error("nickname_already_used: nickname is already in use")
	// ErrEmptyPassword is returned when the password is empty.
	ErrEmptyPassword = errors.Error("empty_password: password is empty")
	// ErrInvalidID si returned when the ID is not a valid UUID or is empty.
	ErrInvalidID        = errors.Error("invalid_id: id is invalid")
	ErrQuestAlreadySent = errors.Error("Нельзя удалить квест, отправленый другу!")
	ErrQuestNotDeleted  = errors.Error("quest not deleted")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
}

DB represents a type for interfacing with database.

type Store

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

Store provides functionality for working with a database.

func New

func New(db DB) *Store

New will instantiate a new instance of Store.

func (*Store) CreateAssignment

func (s *Store) CreateAssignment(ctx context.Context, request model.SendQuestRequest) error

func (*Store) DeleteQuest

func (s *Store) DeleteQuest(ctx context.Context, id string) error

func (*Store) GetAssignment

func (s *Store) GetAssignment(ctx context.Context, questId string, userId string) (*model.Assignment, error)

func (*Store) GetQuest

func (s *Store) GetQuest(ctx context.Context, id string) (*model.QuestWithSteps, error)

GetQuest fetches quest by id

func (*Store) GetQuestsAvailable

func (s *Store) GetQuestsAvailable(ctx context.Context, email string, offset int, limit int, finished bool) ([]model.QuestAvailable, *model.Meta, error)

func (*Store) GetQuestsByUser

func (s *Store) GetQuestsByUser(ctx context.Context, uuid string, offset int, limit int) ([]model.Quest, *model.Meta, error)

GetQuestsByUser will get quests created by user

func (*Store) GetRecipients

func (s *Store) GetRecipients(ctx context.Context, ownerId string, questId string) ([]model.Recipient, error)

func (*Store) InsertQuest

func (s *Store) InsertQuest(ctx context.Context, quest *model.QuestWithSteps) (*model.QuestWithSteps, error)

InsertQuest will add a new quest to the database using the provided data.

func (*Store) UpdateAssignment

func (s *Store) UpdateAssignment(ctx context.Context, questId string, userId *string, currentStep int, status model.Status) error

func (*Store) UpdateQuest

func (s *Store) UpdateQuest(ctx context.Context, quest *model.QuestWithSteps) (*model.QuestWithSteps, error)

Jump to

Keyboard shortcuts

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