storage

package
v0.0.0-...-2db41fb Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package storage - реализует чтение запись в базу всех основных сущностей, Карты, Логины, и тд.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PgStorage

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

func NewPgStorage

func NewPgStorage(conf *config.Config) (*PgStorage, error)

NewPgStorage конструктор хранилища на основе postgresql, явно не используется, только через фабрику

func (*PgStorage) AddBinary

func (p *PgStorage) AddBinary(ctx context.Context, userID int64, binData models.Binary) error

func (*PgStorage) AddCard

func (p *PgStorage) AddCard(ctx context.Context, userID int64, card models.Card) error

func (*PgStorage) AddLogin

func (p *PgStorage) AddLogin(ctx context.Context, userID int64, login models.Login) error

func (*PgStorage) AddText

func (p *PgStorage) AddText(ctx context.Context, userID int64, text models.Text) error

func (*PgStorage) Binary

func (p *PgStorage) Binary(ctx context.Context, userID int64, binID string) (*models.Binary, error)

func (*PgStorage) Card

func (p *PgStorage) Card(ctx context.Context, userID int64, cardID string) (*models.Card, error)

func (*PgStorage) Close

func (p *PgStorage) Close()

func (*PgStorage) DeleteBinary

func (p *PgStorage) DeleteBinary(ctx context.Context, userID int64, binID string) error

func (*PgStorage) DeleteCard

func (p *PgStorage) DeleteCard(ctx context.Context, userID int64, cardID string) error

func (*PgStorage) DeleteLogin

func (p *PgStorage) DeleteLogin(ctx context.Context, userID int64, loginID string) error

func (*PgStorage) DeleteText

func (p *PgStorage) DeleteText(ctx context.Context, userID int64, textID string) error

func (*PgStorage) Login

func (p *PgStorage) Login(ctx context.Context, userID int64, loginID string) (*models.Login, error)

func (*PgStorage) Register

func (p *PgStorage) Register(ctx context.Context, user models.User) (int64, error)

func (*PgStorage) Text

func (p *PgStorage) Text(ctx context.Context, userID int64, textID string) (*models.Text, error)

func (*PgStorage) User

func (p *PgStorage) User(ctx context.Context, login string, password string) (*models.User, error)

func (*PgStorage) UserByLogin

func (p *PgStorage) UserByLogin(ctx context.Context, login string) (*models.User, error)

type Storage

type Storage interface {
	Register(ctx context.Context, user models.User) (int64, error)
	UserByLogin(ctx context.Context, login string) (*models.User, error)
	User(ctx context.Context, login string, password string) (*models.User, error)

	AddCard(ctx context.Context, userID int64, card models.Card) error
	Card(ctx context.Context, userID int64, cardID string) (*models.Card, error)
	DeleteCard(ctx context.Context, userID int64, cardID string) error

	AddLogin(ctx context.Context, userID int64, login models.Login) error
	Login(ctx context.Context, userID int64, loginID string) (*models.Login, error)
	DeleteLogin(ctx context.Context, userID int64, loginID string) error

	AddText(ctx context.Context, userID int64, text models.Text) error
	Text(ctx context.Context, userID int64, textID string) (*models.Text, error)
	DeleteText(ctx context.Context, userID int64, textID string) error

	AddBinary(ctx context.Context, userID int64, binData models.Binary) error
	Binary(ctx context.Context, userID int64, binID string) (*models.Binary, error)
	DeleteBinary(ctx context.Context, userID int64, binID string) error

	Close()
}

Storage описываем интерфейс для записи и чтения в бд, аналогичен HTTP API

Jump to

Keyboard shortcuts

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