storage

package
v0.0.0-...-5d22bd2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewPGSQLStorage = NewDBStorage

Functions

func NewError

func NewError(err error) error

Types

type DBStorage

type DBStorage struct {
	DSN string
	// contains filtered or unexported fields
}

DBStorage - database storage functionality. Use PostgreSQL version 14 or higher as a DBMS.

func (*DBStorage) ConnectRepository

func (s *DBStorage) ConnectRepository(name string, sqlxDB *sqlx.DB) error

func (*DBStorage) GetCategoriesRepository

func (s *DBStorage) GetCategoriesRepository() *repository.CategoriesRepository

func (*DBStorage) GetContractsRepository

func (s *DBStorage) GetContractsRepository() *repository.ContractsRepository

func (*DBStorage) GetFilesRepository

func (s *DBStorage) GetFilesRepository() *repository.FilesRepository

func (*DBStorage) GetMenusRepository

func (s *DBStorage) GetMenusRepository() *repository.MenusRepository

func (*DBStorage) GetSlidersRepository

func (s *DBStorage) GetSlidersRepository() *repository.SlidersRepository

func (*DBStorage) GetUsersRepository

func (s *DBStorage) GetUsersRepository() *repository.UsersRepository

func (*DBStorage) Init

func (s *DBStorage) Init(ctx context.Context, sqlxDB *sqlx.DB) (*sqlx.DB, error)

Init connects to the database using the DSN provided in DBStorage.

type DBStorageInterface

type DBStorageInterface interface {
	Init(ctx context.Context, sqlxDB *sqlx.DB) (*sqlx.DB, error)
	ConnectRepository(name string, sqlxDB *sqlx.DB) error
	GetUsersRepository() *repository.UsersRepository
	GetContractsRepository() *repository.ContractsRepository
	GetMenusRepository() *repository.MenusRepository
	GetSlidersRepository() *repository.SlidersRepository
	GetFilesRepository() *repository.FilesRepository
	GetCategoriesRepository() *repository.CategoriesRepository
}

func NewDBStorage

func NewDBStorage(dsn string) DBStorageInterface

func SetupStorage

func SetupStorage(ctx context.Context, dsn string) (DBStorageInterface, error)

type Error

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

Error = custom storage error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Directories

Path Synopsis
db
Package db contains custom errors for database
Package db contains custom errors for database
repository
Package repository contains all database logic for storage
Package repository contains all database logic for storage
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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