storage

package
v0.0.0-...-9d72d35 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage contains an SQL db. Storage implements the StorageInterface.

func NewPostgresDB

func NewPostgresDB() (*Storage, error)

func (*Storage) AddBook

func (s *Storage) AddBook(ctx context.Context, book model.AddBookRequest) (int, error)

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) DeleteBook

func (s *Storage) DeleteBook(ctx context.Context, id int) error

func (*Storage) GetBook

func (s *Storage) GetBook(ctx context.Context, id int) (model.Book, error)

func (*Storage) GetBooks

func (s *Storage) GetBooks(ctx context.Context) ([]model.Book, error)

func (*Storage) GetDB

func (s *Storage) GetDB() *sqlx.DB

func (*Storage) MigratePostgres

func (s *Storage) MigratePostgres(migrationsPath string) error

MigratePostgres migrates the postgres db to a new version.

func (*Storage) UpdateBook

func (s *Storage) UpdateBook(ctx context.Context, book model.UpdateBookRequest) (int, error)

func (*Storage) VerifyBookExists

func (s *Storage) VerifyBookExists(ctx context.Context, id int) (bool, error)

type StorageInterface

type StorageInterface interface {
	AddBook(ctx context.Context, book model.AddBookRequest) (int, error)
	GetBook(ctx context.Context, id int) (model.Book, error)
	GetBooks(ctx context.Context) ([]model.Book, error)
	UpdateBook(ctx context.Context, book model.UpdateBookRequest) (int, error)
	DeleteBook(ctx context.Context, id int) error
	VerifyBookExists(ctx context.Context, id int) (bool, error)
}

Jump to

Keyboard shortcuts

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