storage

package
v0.0.0-...-de9bcf7 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

type Expression struct {
	ID         int64
	UserID     int64
	Expression string
	Answer     string // Types: null, {answer}
	Date       string
	Status     string // Types: stored, done, error
}

type ExpressionInteractor

type ExpressionInteractor interface {
	InsertExpression(ctx context.Context, expr *Expression) (int64, error)
	SelectExpressionsByID(ctx context.Context, userID int64) ([]Expression, error)
	DeleteExpression(ctx context.Context, id int64) error
	UpdateExpression(ctx context.Context, answer, status string, id int64) error
	SelectAllExpressions(ctx context.Context) ([]Expression, error)
}

Methods for interactions with database

type Storage

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

func New

func New(storagePath string) (*Storage, error)

New - creates new database in the given storagePath with tables

func (*Storage) DeleteExpression

func (s *Storage) DeleteExpression(ctx context.Context, id int64) error

DeleteExpression - deletes expression row from database table

func (*Storage) InsertExpression

func (s *Storage) InsertExpression(ctx context.Context, expr *Expression) (int64, error)

InsertExpression - putting new expression into database table

func (*Storage) LoginUser

func (s *Storage) LoginUser(ctx context.Context, uname, pswrd string) (string, error)

LoginUser selects a user from database and generates new jwt token for him

func (*Storage) RegisterUser

func (s *Storage) RegisterUser(ctx context.Context, uname, pswrd string) error

RegisterUser inserts a new user into database when it registers

func (*Storage) SelectAllExpressions

func (s *Storage) SelectAllExpressions(ctx context.Context) ([]Expression, error)

SelectExpressions - returns all expressions slice from database table

func (*Storage) SelectExpressionsByID

func (s *Storage) SelectExpressionsByID(ctx context.Context, userID int64) ([]Expression, error)

SelectExpressionByID - guess yourself :)

func (*Storage) UpdateExpression

func (s *Storage) UpdateExpression(
	ctx context.Context, answer, status string, id int64,
) error

UpdateExpression - updates data about expression, specifically its answer and/or status

type User

type User struct {
	ID       int64
	Name     string
	Password string
}

Jump to

Keyboard shortcuts

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