Documentation ¶
Index ¶
- type Storage
- func (s *Storage) AddBook(ctx context.Context, book model.AddBookRequest) (int, error)
- func (s *Storage) Close() error
- func (s *Storage) DeleteBook(ctx context.Context, id int) error
- func (s *Storage) GetBook(ctx context.Context, id int) (model.Book, error)
- func (s *Storage) GetBooks(ctx context.Context) ([]model.Book, error)
- func (s *Storage) GetDB() *sqlx.DB
- func (s *Storage) MigratePostgres(migrationsPath string) error
- func (s *Storage) UpdateBook(ctx context.Context, book model.UpdateBookRequest) (int, error)
- func (s *Storage) VerifyBookExists(ctx context.Context, id int) (bool, error)
- type StorageInterface
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 (*Storage) MigratePostgres ¶
MigratePostgres migrates the postgres db to a new version.
func (*Storage) UpdateBook ¶
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) }
Click to show internal directories.
Click to hide internal directories.